-
Notifications
You must be signed in to change notification settings - Fork 226
Migrations
This assumes your DBAs are relinquishing control of the database schema over to using migrations.
- In your generator
<database>.ttsetting file, setSettings.GenerateSeparateFiles = true;and press save to reverse engineer the database. - Enable migrations using the package management console using the command
enable-migrations - 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.
- Delete the
<database>.ttsetting file and theEF.Reverse.POCO.v3.ttincludefile as you will no longer need them. - Inform the DBAs that the database schema is now managed by migrations from now on.
There is no need for migrations in this case as the DBAs will keep the database up to date by applying patches. You have to keep your local development database up to date by applying the same patches the DBAs applied to prod.
After you have applied the patches to your database, you need to update your entity framework DB context and models.
Simply open the <database>.tt file and re-save it. The database is fully reverse engineer each time, so any changes the DBAs made will be brought in. You can then commit this change to source control and do a push.