Reputation: 13
Setup for development on local machine:
ASPNETCORE_ENVIRONMENT
is set to Local
(so that appsettings.local.json
is used for non sensitive configs)AddUserSecrets(...)
)Problem:
ASPNETCORE_ENVIRONMENT
set to Local
, the AddUserSecrets
gets called, but does NOT end up loading the secrets from the secrets.json
file.Couple of interesting observations:
ASPNETCORE_ENVIRONMENT
set to Local
, the AddUserSecrets
gets called and it does load the secrets from secrets.json
successfully -- so loading user secrets for non-development is not a problemASPNETCORE_ENVIRONMENT
set to Development
, the AddUserSecrets
gets called and it does load the secrets from secrets.json
successfully -- so loading user secrets for non application entry points is not a problemNote
How can I get user secrets to be loaded properly when ASPNETCORE_ENVIRONMENT
is NOT development when running EF Core migrations?
Upvotes: 0
Views: 40
Reputation: 5102
As @browsermator mentioned in the comments, from EF Core 5, it will set the ASPNETCORE_ENVIRONMENT
and DOTNET_ENVIRONMENT
environment variables to "Development"
.
But it is possible to set a custom environment when using cli command:
dotnet ef database update -- --environment Local
For more details please check the document.
Upvotes: 0