The first migration environment for the first part of the document 6 Blank up / down

The problem that I am facing is that when I "Add-Migration", it seems that no comparison with the target database is performed, and the Up / Down methods are empty.

It starts with me in different environments. Migration changes work fine when I update the database, and it targets one specific database, my dev database.

When I change the connection string for the target another database, another developer window on another server and try to add-migrate for this particular environment, the Up / Down methods are always empty.

I tried to target the update database to undo changes to the previous migration in the second dev block, but nothing changed.

Is there something I need to do this if I push the first code changes from one environment to another?

+1
source share
3 answers

You do not need to add a new migration, you need to force EF to start all the old ones. Try to specify the source and destination migration:

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

Another option is to create a script that you can run against another database by adding the Script command to the command.

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

If you have many migrations, you can break them down by deleting them and making a new added migration.

+1
source

What I ended up generating the initial migration and then comparing the schema between the two servers (@ Steve Greene commented on a great link describing what I did for comparison here: http://www.techbubbles.com/sql-server/schema -compare-for-sql-server-in-visual-studio-2013 / ). Then I painstakingly went through the migration code and commented on what was not needed.

Once the migration was successful, everything was successful.

I'm not sure there is a better way to handle this, but it worked for me.

+1
source

I struggled with these empty up () and down () appearing with each attempt for several hours. I even tried to start with a new project .. did not work ..

So far I had the idea of ​​setting up a data project in visual studio as the default startup project for the solution .. then the magic happened!

I can’t say if this is a solution (because I still don’t see a connection with the underlying problem), but maybe it can help someone that the space sign of the visual studio is the same as mine :)

+1
source

All Articles