Using DbMigrations on a code first project (c#, 4.5, SQL Server 2012), I've just encountered an error following a table rename operation. This passed validation, but produced an error on the SqlCommand. Steps to reproduce:
1) Create a table called dbo.Foos with columns (id1, id2 and id3) make id1 the Primary key and id3 a Foreign key and add a migration.
3) Run the migration
4) Rename the table in code to dbo.Foo and add a migration
5) Run the migration
6) Alter the Primary key to be both id1 and id2: table.HasKey(new{id1,id2}); and add a migration
7) Attempt to run the migration
Error is produced as the table rename operation in step 4 did not rename the keys!
System.Data.SqlClient.SqlException (0x80131904): 'PK_dbo.Foo' is not a constraint.
Could not drop constraint.
1) Create a table called dbo.Foos with columns (id1, id2 and id3) make id1 the Primary key and id3 a Foreign key and add a migration.
3) Run the migration
4) Rename the table in code to dbo.Foo and add a migration
5) Run the migration
6) Alter the Primary key to be both id1 and id2: table.HasKey(new{id1,id2}); and add a migration
7) Attempt to run the migration
Error is produced as the table rename operation in step 4 did not rename the keys!
System.Data.SqlClient.SqlException (0x80131904): 'PK_dbo.Foo' is not a constraint.
Could not drop constraint.