Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@rushi216
Last active December 11, 2016 14:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rushi216/894491a87f3c13f14b0686073931939d to your computer and use it in GitHub Desktop.
Save rushi216/894491a87f3c13f14b0686073931939d to your computer and use it in GitHub Desktop.

Code based:

Simple:

Just Enable-Migrations and Add-Migration everytime when you update model then Update-Database

Simple without running Update-Database everytime manually (however add-migration is necessary):

Use Database.SetInitializer at app startup like below:

Database.SetInitializer(new MigrateDatabaseToLatestVersion<AppContext, Configuration>());

Automatic (no need for add-migration but you still have to use update-database):

Enable-Migrations -EnableAutomaticMigrations (or just apply true to Configuration.cs class)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment