How do I run ASP.NET Core Entity Framework migrations from Visual Studio Team Services

asp.net-core azure-devops c# entity-framework-core visual-studio-2017

Question

I've got a Web API project created using ASP.NET Core 1.1. I use Entity Framework Core Migrations. Locally, that all works well.

However, I'm trying to use Visual Studio team services to automatically run the migrations when I do a release and can't figure out how to do this. Is there some inbuilt component, or should I try to get the dotnet ef tools installed on the agent and run it that way?

1
3
6/25/2017 11:54:29 AM

Accepted Answer

I would suggest using the dotnet ef tools (during VSTS Build) to generate a .sql script which could be used to generate or update your database wherever needed (during the Release).

dotnet ef migrations script -o migration-script.sql -i -v

During Release amongst other options you could run Invoke-SqlCmd:

Invoke-SqlCmd -inputfile "$inputFile" -serverinstance "$serverInstance" -username "$serverUserName" -password "$serverPassword" -database "$database"
1
10/24/2017 8:52:50 AM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow