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

只愿长相守 提交于 2019-12-06 08:11:26

问题


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:


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"


来源:https://stackoverflow.com/questions/44746103/how-do-i-run-asp-net-core-entity-framework-migrations-from-visual-studio-team-se

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!