Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

change environment during database update [duplicate]

i am trying to update my database but dotnet ef database update uses wrong ASPNETCORE_ENVIRONMENT In log I see this Using environment 'Development' instead ofLocal`

this is my command :

dotnet ef database update --startup-project ../API --configuration Local --verbose

"Local": {
      "commandName": "IISExpress",
      "launchBrowser": true,
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Local"
      }
    },

I also tried to use --environment Local but environment isn't defined as option even if https://github.com/aspnet/EntityFrameworkCore/issues/7353 states otherwise

like image 615
user1075940 Avatar asked Mar 29 '26 00:03

user1075940


1 Answers

It seems that you need to run this command before the database update:

$Env:ASPNETCORE_ENVIRONMENT = "Local"
like image 171
user1075940 Avatar answered Apr 02 '26 03:04

user1075940



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!