Reputation: 1312
Using MVC4 and EF Code First
I renamed my table/column-name i.e. table: from Categories to Category in the model and in the code and when I run the migration statement
Update-Database -Verbose -Force
I get an error:
The CREATE UNIQUE INDEX statement terminated because a duplicate key was found for the object name 'dbo.Categories' and the index name 'PK_dbo.Categories'. The duplicate key value is (). Could not create constraint. See previous errors. The statement has been terminated.
In the configuration file I have AutomaticMigrationsEnabled = true;
Is there something else I need to do to make the changes apply in the database?
Upvotes: 0
Views: 673
Reputation: 11544
You cannot modify the PK.
1 - Delete existing database then run Update-Database
2 - Generate update script by running Update-Database -Script
and add drop index TSQL to generated file and run the script.
3 - Remove key constrain from table via Visual Studio or Management Studio then remove TSQL for dropping index in generated script then run script.
Upvotes: 2