Skip to content

Migrations

Simon Hughes edited this page Aug 23, 2020 · 6 revisions

Converting your database to use migrations moving forward

This assumes your dba's are relinquishing control of the database schema over to using migrations.

  1. In your generator <database>.tt setting file, set Settings.GenerateSeparateFiles = true; and press save to reverse engineer the database.
  2. Enable migrations using the package management console using the command enable-migrations
  3. Add your first migration using the command Add-Migration Init -IgnoreChanges

    -IgnoreChanges Scaffolds an empty migration ignoring any pending changes detected in the current model. This can be used to create an initial, empty migration to enable Migrations for an existing database. Note: Doing this assumes that the target database schema is compatible with the current model, which is exactly what you now have.

  4. Delete the <database>.tt setting file and the EF.Reverse.POCO.v3.ttinclude file as you will no longer need them.
  5. Inform the dba's that the database schema is now managed by migrations from now on.

Clone this wiki locally