ef core don´t use ASPNETCORE_ENVIRONMENT during update-database

后端 未结 4 765
情话喂你
情话喂你 2020-12-04 17:40

I use visual studio to update all my environments with a certain migration. It had worked fine using the command below.

update-database -Migration initMigrat         


        
4条回答
  •  没有蜡笔的小新
    2020-12-04 18:06

    I had the same problem like the reporter of this issue and tried out the recent solution in the Package Manager Console (PMC) and set the environment variable with the command:

    $env:ASPNETCORE_ENVIRONMENT='YOUR_ENVIRONMENT'
    

    Unfortunetly I have a ConsoleApplication and use the generic host builder on startup with Host.CreateDefaultBuilder(). In this scenario the environment variable prefix is not ASPNETCORE_ but DOTNET_.

    For me this command works in PMC:

    $env:DOTNET_ENVIRONMENT='YOUR_ENVIRONMENT'
    

    I want to thank Martin Florin and others to guide me in the correct direction.

提交回复
热议问题