Skip to content
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

Show how to use ASPNETCORE_ENVIRONMENT with Migrations #1050

Closed
zuckerthoben opened this issue Oct 11, 2018 — with docs.microsoft.com · 3 comments · Fixed by #2813
Closed

Show how to use ASPNETCORE_ENVIRONMENT with Migrations #1050

zuckerthoben opened this issue Oct 11, 2018 — with docs.microsoft.com · 3 comments · Fixed by #2813

Comments

Copy link

zuckerthoben commented Oct 11, 2018

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.

@bricelam
Copy link
Contributor

Note to documenter: Mention DOTNET_ENVIRONMENT too

@Rick-Anderson
Copy link
Contributor

Rick-Anderson commented Sep 17, 2020

Add a link to https://docs.microsoft.com/aspnet/core/fundamentals/environments
[Use multiple environments](/aspnet/core/fundamentals/environments)

@bricelam
Copy link
Contributor

Note, in EF Core 5.0, you can pass it into the host builder via an argument without having to set the environment variable:

dotnet ef database update -- --environment Production

bricelam added a commit to bricelam/EntityFramework.Docs that referenced this issue Oct 27, 2020
Additional changes:

- Add tips about EXEC (fixes dotnet#2561)
- Add a tab for Get-Migration
- Update custom operation samples (fixes dotnet#1574)
- Fix some bad PMC examples (fixes dotnet#2296)
- Add examples using Name= (fixes dotnet#2145)

Fixes dotnet#1050
bricelam added a commit to bricelam/EntityFramework.Docs that referenced this issue Oct 27, 2020
Additional changes:

- Add tips about EXEC (fixes dotnet#2561)
- Add a tab for Get-Migration
- Update custom operation samples (fixes dotnet#1574)
- Fix some bad PMC examples (fixes dotnet#2296)
- Add examples using Name= (fixes dotnet#2145)

Fixes dotnet#1050
bricelam added a commit to bricelam/EntityFramework.Docs that referenced this issue Oct 28, 2020
Additional changes:

- Add tips about EXEC (fixes dotnet#2561)
- Add a tab for Get-Migration
- Update custom operation samples (fixes dotnet#1574)
- Fix some bad PMC examples (fixes dotnet#2296)
- Add examples using Name= (fixes dotnet#2145)

Fixes dotnet#1050
bricelam added a commit to bricelam/EntityFramework.Docs that referenced this issue Oct 28, 2020
Additional changes:

- Add tips about EXEC (fixes dotnet#2561)
- Add a tab for Get-Migration
- Update custom operation samples (fixes dotnet#1574)
- Fix some bad PMC examples (fixes dotnet#2296)
- Add examples using Name= (fixes dotnet#2145)
- Mention ExcludeFromMigrations (fixes dotnet#750)

Fixes dotnet#1050
bricelam added a commit to bricelam/EntityFramework.Docs that referenced this issue Oct 28, 2020
Additional changes:

- Add tips about EXEC (fixes dotnet#2561)
- Add a tab for Get-Migration
- Update custom operation samples (fixes dotnet#1574)
- Fix some bad PMC examples (fixes dotnet#2296)
- Add examples using Name= (fixes dotnet#2145)
- Mention ExcludeFromMigrations (fixes dotnet#750)
- Rearrange connection strings page

Fixes dotnet#1050
bricelam added a commit to bricelam/EntityFramework.Docs that referenced this issue Oct 29, 2020
Additional changes:

- Add tips about EXEC (fixes dotnet#2561)
- Add a tab for Get-Migration
- Update custom operation samples (fixes dotnet#1574)
- Fix some bad PMC examples (fixes dotnet#2296)
- Add examples using Name= (fixes dotnet#2145)
- Mention ExcludeFromMigrations (fixes dotnet#750)
- Rearrange connection strings page
- Use OutputDir instead of Namespace

Fixes dotnet#1050
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants