Question

I have a problem with code first migrations. When I'm deploying the site the database updates, but the new migrations doesn't inserts in the "__MigrationHistory" table. So everytime after I have published I need to insert the records manually into the "__MigrationHistory" table from the DEV database.

In my global.asax.cs on Application_Start. I have this part of code

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

When im publishing i check the option "publish database", and the website is hosted in azure. I'm using entity framework 6.1.0

Was it helpful?

Solution

The problem was in the deploy process. After I upgraded Visual Studio 2013, the option "Execute Code First Migrations (runs on application start)" is gone and has been substituted with "Update Database". If I uncheck the "Update Database" an only have this in Application_Start, everything works fine.

Database.SetInitializer<MmContext>(new MigrateDatabaseToLatestVersion<MmContext, Configuration>());
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top