How Do I Run EF Core Migrations with VSTS Deployment to Azure for Web API Project

azure-devops entity-framework-core

Question

My project was created via dotnet new webapi --name=ProjectName. I've setup a build definition in VSTS. The Deployment to Azure runs fine, but I can't figure out how to run my migrations, i.e., dotnet ef database update

I've reviewed several of the other Stack Overflow questions. Though helpful, none of them provided a current solution. References:

The closest I've come to being successful is adding tasks like so:

  • Replace Tokens: Update Connection String
  • Command Line: set ASPNETCORE_ENVIRONMENT=Production
  • Command Line: dotnet ef database update -v

This almost works, but for some reason ef still targets development.

Any recent solutions?

1
3
3/14/2018 2:07:38 PM

Accepted Answer

Adding ASPNETCORE_ENVIRONMENT variable to build/release definition and specify Production value.

2
3/15/2018 2:09:36 AM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow