I have a entity as follows
[Table(\"ESS_POS_SE_VERSION\")]
public class Version
{
[Key, Column(\"DETAIL_ID\"), DatabaseGenerated(DatabaseGeneratedOption.
Consider creating a custom database initializer. It will be called each time your database is created or recreated.
For example:
public class MyInitializer : DropCreateDatabaseIfModelChanges<TContext> where TContext : DbContext
{
protected override void Seed(TContext context)
{
context.Database.ExecuteSqlCommand("DBCC CHECKIDENT('MyTable', RESEED, 1000);");
}
}
Then register it:
protected void Application_Start()
{
Database.SetInitializer<MyContext>(new MyInitializer());
}
There is no way to set through Property or Attribute. However, you can run the command on this event:
Probably you can set through Alter: ALTER TABLE [MyTable] ALTER COLUMN [IdentityColumn] IDENTITY (1000,1).
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{ context.Database.ExecuteSqlCommand(ALTER TABLE [MyTable] ALTER COLUMN [IdentityColumn] IDENTITY (1000,1)) }
context.Database.ExecuteSqlCommand("ALTER TABLE Version ALTER COLUMN DETAIL_ID IDENTITY (1000,1)");