Code First Migration Entity Framework 6 Empty Up/Down

ef-migrations entity-framework-6

Question

The issue I'm having is that it appears that no comparison against the target database is made when I "Add-Migration," and the Up/Down methods are empty.

I begin by focusing on various environments. When I update-database and it just targets one database, my development database, the migration changes function as intended.

The Up/Down methods are never empty when I try to add migration for that specific environment after changing the connection string to target a different database, another development box on a different server, etc.

I attempted to target an update-database to the second development box to roll back modifications made during a previous migration, but nothing changed.

Is there anything in particular I should do when moving code-first changes between environments?

1
1
4/24/2015 3:10:30 PM

Accepted Answer

Instead of adding a new migration, you must command EF to execute all the existing ones. Attempt defining the migrations' source and target:

Update-Database -SourceMigration: $InitialDatabase -TargetMigration: AddPostAbstract  

By adding -Script to the command, you can also create a script that you can run on the other database.

look at https://msdn.microsoft.com/en-us/data/jj591621.aspx#script

You could role up your migrations if you have a lot of them by eliminating them and performing a brand-new add-migration.

2
4/24/2015 6:27:22 PM

Popular Answer

ZZZ_tmp


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow