-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
-Environment argument removed from Update migration command and ASPNETCORE_ENVIRONMENT ignored #9623
Comments
@ihandley Make sure that the environment variable is set correctly in PowerShell. Something like, $env:ASPNETCORE_ENVIRONMENT="Staging" |
I have tried this. No dice. |
It works for me, although I preferred the older way: #9664 |
@ihandley Can you run get-childitem env: in the PMC after setting the environment but before running the migration command and check that the environment variable is set? If so and this is still not working then are you doing anything different/unusual in the PMC window? Would it be possible to attach a project where this happens so we can debug? |
Well that's strange. Last week I when I was setting the environmental variable as you first suggested, it didn't appear to have any effect on my migration commands. However, this morning I tried it and it worked! The ol' car at the mechanic phenomenon. It still seems like setting the environmental variable in the project properties isn't being recognized. Is that a known issue? Is the only way of switching environments at this point to do it manually in the CLI or PMC? |
Correct. Hosting reads the environment variable during startup. While environment variables can be read using project properties, the opposite is not true--project properties aren't exported to environment variables. |
The old way (using the -e switch) was far superior for those of supporting multiple runtime environments for our apps. |
I am simply unable to do a migration to my staging environment.
From what I've read here, the environment argument was removed and we should now be able to use the ASPNETCORE_ENVIRONMENT environment variable to target environments other than development. I recognize those docs may not be current, but I have been unable to find anything else relevant to my issue anywhere else. I've tried using the CLI and the PMC with the same result.
This is the first part of what I'm seeing when I run Update-Database in the PMC:
Notice the
Using environment 'Development'.
bit even though I have my ASPNETCORE_ENVIRONMENT environment variable set to Staging.Further technical details
EF Core version: 2.0.0
Database Provider: Microsoft.EntityFrameworkCore.SqlServer
Operating system:
IDE: Visual Studio 2017
The text was updated successfully, but these errors were encountered: