Efcore: Deployment and Database Creation/Migration

Created on 22 May 2014  路  6Comments  路  Source: dotnet/efcore

For local development we introduced a piece of middleware in ASP.NET 5 that provides instruction on using migrations.

We are currently working to replace the 'apply migrations on app start' functionality with something better.

blocked type-enhancement

Most helpful comment

Apply migrations during publish is now enabled and will ship in RC2... and the nasty apply migrations code in Startup.cs is being removed from the templates 馃帀 馃巻 馃拑

All 6 comments

For deployment to Azure (which is one of the key Right Click -> Publish scenarios in VS) I have prototyped using Azure WebJobs (with a triggered job) to apply migrations during deployment and it works pretty nicely. You can just invoke k ef migration apply on the code base using the version of KRE that is deployed with the app.

Will discuss with @sayedihashimi when he is back in the office.

Here is a sample of the WebJob command I was using. This is very similar to the *.cmd files we already produce when publishing to disk.

"%HOME%\site\approot\packages\KRE-CLR-x86.1.0.0-beta2-10709\bin\klr.exe" --appbase "%HOME%\site\approot\src\ToDo" Microsoft.Framework.ApplicationHost ef migration apply --context "ToDo.Models.ApplicationDbContext"

Assigning temporarily to myself to follow up with the tooling folks to figure out how we land this in RC2.

I know this issue is primarily about the VS right-click Publish integration story, but do you also have any recommendations for how to manage migrations for customers using git deployment (Kudu) to Azure?

I have several web apps using that deployment scenario, and for now I鈥檝e just settled with using ef migrations script -i and running the script from my client machine. Would it make sense instead to use a custom Kudu deployment script that, similar to the process outlined here, would run ef migrations script -i and use MsDeploy to execute the script during deployment?

I wouldn鈥檛 expect any official tooling support, but it would be great if there was some guidance (even just a paragraph in the docs or wiki) with a recommended approach to using migrations with Kudu deployments.

@ryanerdmann I've opened https://github.com/aspnet/EntityFramework/issues/5207 to sort this out.

Apply migrations during publish is now enabled and will ship in RC2... and the nasty apply migrations code in Startup.cs is being removed from the templates 馃帀 馃巻 馃拑

Was this page helpful?
0 / 5 - 0 ratings