Run EF migration on VSTS release

北城余情 提交于 2019-12-02 12:07:18

问题


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 ?


回答1:


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.



来源:https://stackoverflow.com/questions/44957938/run-ef-migration-on-vsts-release

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