Generate full SQL script from EF 5 Code First Migrations

Matt Wilson picture Matt Wilson · Dec 18, 2012 · Viewed 108.9k times · Source

How do I use Entity Framework 5 Code First Migrations to create a full database script from the initial (empty) state to the latest migration?

The blog post at MSDN Blog suggests to do this, but it seems to create an empty script:

Update-Database -Script -SourceMigration: $InitialDatabase

Answer

Matt Wilson picture Matt Wilson · Dec 18, 2012

The API appears to have changed (or at least, it doesn't work for me).

Running the following in the Package Manager Console works as expected:

Update-Database -Script -SourceMigration:0