如何从Visual Studio Team Services运行ASP.NET Core Entity Framework迁移

编程入门 行业动态 更新时间:2024-10-23 07:32:15
本文介绍了如何从Visual Studio Team Services运行ASP.NET Core Entity Framework迁移的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个使用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迁移

本文发布于:2023-11-23 04:57:50,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1620168.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Team   Services   Visual   Studio   ASP

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!