我有一个使用ASP.NET Core 1.1创建的Web API项目.我使用实体框架核心迁移.在本地,一切都很好.
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.
但是,我正在尝试使用Visual Studio团队服务在发布时自动运行迁移,但无法弄清楚该怎么做.是否有一些内置组件,还是应该尝试在代理上安装dotnet ef工具并以这种方式运行它?
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?
推荐答案我建议使用dotnet ef工具(在VSTS Build期间)生成一个.sql脚本,该脚本可用于在需要的地方生成或更新数据库(在版本).
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在Release期间,您可以运行Invoke-SqlCmd:
During Release amongst other options you could run Invoke-SqlCmd:
Invoke-SqlCmd -inputfile "$inputFile" -serverinstance "$serverInstance" -username "$serverUserName" -password "$serverPassword" -database "$database"更多推荐
如何从Visual Studio Team Services运行ASP.NET Core Entity Framework迁移
发布评论