How to: Perform ASP.NET Core Entity Framework Migrations from Visual Studio Team Services

I have a Web API project built using ASP.NET Core 1.1. I am using Entity Framework Core Migrations. Locally that everything works well.

However, I am trying to use Visual Studio Team Services to automatically start migrations when I make a release and cannot figure out how to do it. Is there a built-in component, or should I try to get the dotnet ef tools installed on the agent and run it this way?

+3


source to share


1 answer


I would suggest using the dotnet ef tools (at VSTS build time) to create a .sql script that could be used to generate or update your database where needed (at release time).

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

      



At release time, among other parameters, you can run Invoke-SqlCmd:

Invoke-SqlCmd -inputfile "$inputFile" -serverinstance "$serverInstance" -username "$serverUserName" -password "$serverPassword" -database "$database"

      

0


source







All Articles