I’ve been really excited with the new Windows Azure Websites recently. As a long time AppHarbor user, deploying ASP.NET MVC app to the cloud via a git push is extremely nice.

Something strange happened to me on my last project though. After creating a basic working prototype of the app I was ready to deploy the application. Since it’s a small prototype for now I was using the Visual Studio Publishing Wizard.

I had enable migrations on the project, created some models and my DbContext class, everything was working nicely. On the Publishing Wizard I was seeing this:


The Enable Code First Migrations check box was not present, and my DbContext class was not displayed. The wizard should look like this:


After a couple of time (hours?) of digging, I finally find where the thing is configured.


Manually editing the pubxml file to make the check box appear

You can enable that check box by editing the Properties\YourProject - WebDeploy.pubxml look for the PublishDatabaseSettings

      <Objects xmlns="">  
        <ObjectGroup Name="Namespace.Models.YourDBClass" Order="1" Enabled="True">  
          <Destination Path="your-connection-string-goes-here" />  
          <Object Type="DbCodeFirst">  
            <Source Path="DBMigration" DbContext="Namespace.Models.YourDBClass, AssamblyName" MigrationConfiguration="Namespace.Migrations.Configuration, Assambly" Origin="Convention" />  

Change Namespace.Models.YourDBClass by your class that inherits DbContext, change Namespace.Migratins.Configuration to fit your migration configuration namespace and Assambly with your Assambly name.

Save and open the publish wizard you will have that check box.

I’ve took the VS Publishing Wizard from that stackoverflow question I’ve answered.

Technorati Tags: Windows Azure,Publishing Wizard,EF Code First Migrations