Using Entity Framework 4.3 migration without depending on the actual database

The EF migrations seem cool, but there is too much β€œmagic” and very little explanation about what it actually does. All I want to do is set the intersection points and get the DDL scripts - either a "diff" script from one transition to another, or just create a DDL script.

The problem is that all migration commands seem to be dependent on the actual database present to do a lot of things that are not interesting to me. Is there a way around this and just work with migrations to generate scripts?

+4
source share
1 answer

This was discussed yesterday . The migration commands are dependent on your production database because they interact with the __MigrationHistory table to get the actual state and correctly calculate what changes need to be made.

If you just need to create scripts, you can do this using Update-Database with additional parameters:

Create a script for the entire database:

 Update-Database -Script -SourceMigration:$InitialDatabase 

Create a script to move from migration A to migration B:

 Update-Database -Script -SourceMigration:"A" -TargetMigration:"B" 
0
source

Source: https://habr.com/ru/post/1415051/


All Articles