In my current web project, I am trying to configure code migration. I installed my db initializer as follows in my MVC4 project
protected void Application_Start() { Database.SetInitializer(new MigrateDatabaseToLatestVersion<MyContext, Configuration>()); }
I can make changes to my first code models, and this updates the database to the last automatic migration, as expected when starting the website.
However, I am trying to add explicit migration through the Add-Migration FirstMigration console to add some indexes. This adds the code file 201301071708126_FirstMigration to my project, and I can add it to my index code quite easily here.
But it will not start automatically when you restart the website. I need to run Update-Database from the console in order to apply this migration.
I followed this msdn tutorial , but I donβt see what I am doing wrong, as it suggests me that explicit migration starts automatically.
In my configuration file, I have the following constructor
public Configuration() { AutomaticMigrationsEnabled = true; AutomaticMigrationDataLossAllowed = true; }
source share