How to run EF migrations when deployed to Azure Website through Visual Studio Online

I have an Azure site configured to deploy from Visual Studio Online (hosted by TFS). I am evaluating the transition from the First Model database to Code First from an existing database model.

Currently, when I register code for Visual Studio Online, it is deployed to the Azure website. How to configure this process to run EF Migrations on a remote (live or test) Azure SQL database when entering a registration code in Visual Studio Online.

+6
source share
2 answers

AFAIK, for this you need to use the publish option.

You need to load the settings file to publish the profile for the website, import the file into Visual Studio, configure the Run the first migration code option, and then specify the profile file path in the assembly definition used for continuous deployment.

You can check the below message for reference.

http://blogs.msdn.com/b/webdev/archive/2014/04/09/ef-code-first-migrations-deployment-to-an-azure-cloud-service.aspx

+4
source

I know this is an old post, but I did not find a good answer, therefore, finding out how to solve it, I share the solution. I am working on a project with DDD and N-tiers. Thus, this means that EF is not in the same project as WebApi, therefore it is not able to start the migration during the publication wizard. To solve this problem, I started the update database directly from the package manager console.

Steps:

what all!

Best regards, Thiago

+2
source

All Articles