You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Show how to use ASPNETCORE_ENVIRONMENT with Migrations #1050
The mentioned section misses to explain some (for me) important details you need if you want to use this approach:
The call Program.BuildWebHost is implicitly called with an ASPNETCORE_ENVIRONMENT setting of "development". That means that if you read the connection string from e.g. the appsettings inside AddDbContext, you need to have an appsettings file for this environment variable. Otherwise the root appsettings will be used, which means that you have to also copy the connection string to the database you want to use to this file. Otherwise this approach will fail, because it cant find the connection string.
Also in general the application needs to be able to start with the "development" env variable. If it for some reason does not build, you might face exceptions that you can't associate with the source of the problem.
My proposal:
Further explain the behavior of the mentioned section, including the implicit usage of "development" as env var
Perhaps give a short example on how to use this approach in practice
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
ID: 2fa64390-1232-8dd3-f170-7d5c68e29ad9
Version Independent ID: 245bbba8-3102-4a66-15eb-650e05eb9e62
Activity
[-]Expand the section "From application services"[/-][+]Show how to use ASPNETCORE_ENVIRONMENT with Migrations[/+]bricelam commentedon Aug 25, 2020
Note to documenter: Mention DOTNET_ENVIRONMENT too
Rick-Anderson commentedon Sep 17, 2020
Add a link to https://docs.microsoft.com/aspnet/core/fundamentals/environments
[Use multiple environments](/aspnet/core/fundamentals/environments)bricelam commentedon Sep 22, 2020
Note, in EF Core 5.0, you can pass it into the host builder via an argument without having to set the environment variable:
Document passing design-time args
Document passing design-time args
Document passing design-time args
Document passing design-time args
Document passing design-time args
Document passing design-time args
Document passing design-time args