Let's say I have connection string for Development environment specified in appsettings.Development.json
and connection string for the Staging environment specified in appsettings.Staging.json
All I need to do to switch between Development and Staging is to navigate to Visual Studio Debug tab in project properties and change the value for ASPNETCORE_ENVIRONMENT
environment variable.
Now, of course I don't want to have connection string in appsettings.*.json
for security reasons. So I move it to User Secrets.
Problem is - it seems there is just one secrets.json
file that is used by all the environments. There are no secrets.Development.json
or secrets.Staging.json
. This means after I switch from Development to Staging environment via Visual Studio Debug tab I then also need to change connection strings manually in secrets.json
which kind of defeats the purpose of having built-in support for the environments.
Is this correct that User Secrets are not supported on per-environment basis? If so - is there another approach that would avoid having to modify Secret connection string manually when switching environments?