在VSTS版本上运行EF迁移 [英] Run EF migration on VSTS release

查看:193
本文介绍了在VSTS版本上运行EF迁移的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我将Asp.Net MVC应用程序发布到使用VSTS和Hosted VS2017代理的azure网络应用程序时,EF Migration(到Azure SQL)不会在应用程序启动时执行,可以从Visual Studio中完成发布选项执行代码首次迁移(在应用程序启动时运行)。



VSTS的具体步骤将使EF迁移运行并将数据库更新相同从VS发布的方式?

解决方案

可以让VSTS使用与VS中相同的发布配置文件,在我的情况下一个Web部署流程到Azure Web App,并包括在应用程序启动时运行迁移的选项。



在VSTS构建定义变量选项卡中,添加以下条目: p>

DeployOnBuild:true



PublishProfile:NameOfTheVSPublishProfileFile



DesktopBuildPackageLocation :$(System.DefaultWorkingDirectory)/MyBuildFolderName/drop/MyProjectZipName.zi p



然后构建和发布。



下次运行应用程序时,新的迁移将以相同的方式执行从VS发布的方式。


When I release my Asp.Net MVC app to azure web app using VSTS and a Hosted VS2017 agent, the EF Migration (to Azure SQL) doesn't execute on application start the same way it can be done publishing from Visual Studio with the option "Execute Code First Migrations (Runs on application start)".

What would be the specific steps on VSTS to make EF migration run and update the database the same way as when publishing from VS ?

解决方案

Is possible to have VSTS use the same Publish Profile as in VS which in my case is a Web Deploy process to Azure Web App and includes the option to run migrations on application start.

In the VSTS build definition, Variables tab, add the following entries:

DeployOnBuild: true

PublishProfile: NameOfTheVSPublishProfileFile

DesktopBuildPackageLocation: $(System.DefaultWorkingDirectory)/MyBuildFolderName/drop/MyProjectZipName.zip

Then Build and Release.

Next time you run the app the new migrations will execute in the same way as when publishing from VS.

这篇关于在VSTS版本上运行EF迁移的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆