Code First Migration Entity Framework 6 Empty Up/Down

ef-migrations entity-framework-6


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

This starts from me targeting different environments. The migration changes work fine when I update-database and it targets one particular database, my dev database.

When I change the connection string to target another database, another dev box on another server, and try to add-migration for that particular environment, the Up/Down methods are always empty.

I tried targeting an update-database to roll back changes to a previous migration at the 2nd dev box but it didn't change anything.

Is there anything that I need to specifically do if I'm migrating code-first changes from one environment to another?

4/24/2015 3:10:30 PM

Accepted Answer

You don't need to add a new migration, you need to force EF to run all the old ones. Try specifying the source and target migrations:

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

Another option would be to generate a script that you can run against the other database by adding -Script to the command.


If you have a lot of migrations you could role them up by deleting them and doing a fresh add-migration.

4/24/2015 6:27:22 PM

Popular Answer

I've been struggling with this empty up() and down() showing up at every attempt for hours. Tried even starting over a new project .. didn't work ..

Until I've had the idea of setting up, in visual studio, the data project as the default startup project of the solution .. then magic happened!

Can't really say if it's a solution (because I still don't see the connection to the base problem) but may be it could help somebody which visual studio's cosmic sign is the same as mine :)

Related Questions


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