Code-First Migrations: AlterColumn throws exception when changing identity to true
Posted: Thu 04 Dec 2014 09:26
Hi,
when changing an entity key from DatabaseGeneratedOption.None to DatabaseGeneratedOption.Identity the following migration code block will throw an exception:
The exception says "serial does not exist". I also sent you an sample project to reproduce this issue.
when changing an entity key from DatabaseGeneratedOption.None to DatabaseGeneratedOption.Identity the following migration code block will throw an exception:
Code: Select all
DropPrimaryKey("dbo.TestTables");
AlterColumn("dbo.TestTables", "TestTableID", c => c.Int(nullable: false, identity: true));
AddPrimaryKey("dbo.TestTables", "TestTableID");