Asp.net-mvc – Entity Framework 6.0 Code First Migrations to Azure SQL DB not working.

asp.net-mvcazureentity-frameworkentity-framework-migrations

I am trying to create an ASP.NET MVC site loosely based on this tutorial.
http://www.windowsazure.com/en-us/develop/net/tutorials/web-site-with-sql-database/

I am using VS2013 preview which gave me the option to create an ASP.NET MVC 5 site. Also, using the following packages:

EntityFramework 6.0.0-rc1

Microsoft.AspNet.Identity.Core" 1.0.0-alpha1

Microsoft.AspNet.Identity.EntityFramework 1.0.0-alpha1

After configuring a website and associating it with a database in Azure, I proceeded to run the following commands in the package manager console:

enable-migrations -ContextTypeName IdentityDbContext

add-migration Initial

When I published to Azure with the database specified and the "Execute Code First Migrations" checkbox checked, the site deployed properly, but after inspecting my DB, the migrations didn't run. My migrations had been successful previously on a site with ASP.Net MVC 4 and EF 5.0.

I would guess the problem is that EF 6 is ignoring the connection string that is set during publishing, but I cannot understand why.

Any help would be appreciated. Thank you.

Best Answer

This guide looks comprehensive: http://www.asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/migrations-and-deployment-with-the-entity-framework-in-an-asp-net-mvc-application

The key part being "Execute Code First Migrations (runs on application start)"

I hope that helps.