Question

I'm using Windows Azure to host an ASP.NET MVC4 web application. I want to use database first-programming, and followed this tutorial to create a database and data model.

I then created a website with a linked database in Windows Azure. I downloaded the publish profile and imported it through VS2012 into the project. I noticed that the database connection strings were not included, so I collected it from the database created in Azure.

In the publish wizard under tab "Settings" I was able to to check a box called "Update database" and when I published the website for the first time, everything went perfect and the website and database was uploaded.

Then I did some changes to the database, updated the data model as described in above mentioned tutorial, updated my code and built the project. This time, when I entered the Publish wizard and selected the "Settings" tab, I am no longer able to check the "Update database" checkbox. Instead there is a disabled checkbox called "Execute Code First Migrations (runs on application start)".

Why can I no longer select the "update database" checkbox? Do I have to update the database manually from now? I tried to create the datamodel again, but it did not help.

Was it helpful?

Solution

This is a completely normal behavior. You set that option for the first time and on successive deployments the code-first migrations will take place on application start. EF (Entity framework) will start the Code-First migrations then.

Especially when you update your model manually.

You will not have to update your database manually. It will be done on application start. When your web-app is started, if you select the migration option.

Read more in detail here:

EF Code First Migrations Deployment to an Azure Cloud Service

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top