The initial migration across a schema change works correctly, but then if the project is reverted and then updated again issues arise.
Repro:
create a project
Enable-Migrations
Add-Migration m0/Update-Database
F5 with the default schema (populate database)
change DbContext schema
Add-Migrations m1/Update-Database
run
Update-Database -TargetMigration m0
run
Update-Database
error -> The object with the name "Posts" already exists
Comments: More testing completed, the root cause of this error was due to running the application with inconsistencies between the model and the database (in this case, when reverting to m0 the schema was left different causing the table to be recreated instead of moved)
Repro:
create a project
Enable-Migrations
Add-Migration m0/Update-Database
F5 with the default schema (populate database)
change DbContext schema
Add-Migrations m1/Update-Database
run
Update-Database -TargetMigration m0
run
Update-Database
error -> The object with the name "Posts" already exists
Comments: More testing completed, the root cause of this error was due to running the application with inconsistencies between the model and the database (in this case, when reverting to m0 the schema was left different causing the table to be recreated instead of moved)