ASPNETCORE_ENVIRONMENT does not default to Development when using EF Core 9 if there is a IDesignTimeDbContextFactory implementation #35174
Labels
area-migrations
area-tools
closed-fixed
The issue has been fixed and is/will be included in the release indicated by the issue milestone.
customer-reported
regression
type-bug
Milestone
Running
dotnet ef database update
while using EF Core 8.0.11 or earlier used to set ASPNETCORE_ENVIRONMENT and DOTNET_ENVIRONMENT to "Development" if it was not explicitly specified. On updating to EF Core 9, those do not default if there is an implementation ofIDesignTimeDbContextFactory
. The version of dotnet-ef (at least between 9.0.0 and 8.0.11) does not seem to matter.I believe this is the code in question, though I haven't managed to chase down why it's not being hit for 9.0.0 with
IDesignTimeDbContextFactory
.This project can be manipulated to reproduce the issue, though I've also included some relevant tool output from
dotnet ef database update --project .\ReproTest\ --verbose
below.My current workaround is to explicitly set the Environment as described at https://learn.microsoft.com/en-us/ef/core/cli/dotnet#aspnet-core-environment .
Provider and version information
EF Core version:
Database provider: Microsoft.EntityFrameworkCore.SqlServer
Target framework: .NET 8 and 9
Operating system: Windows 11 23H2, 22631.4460
IDE: Visual Studio 2022 17.12.0
Log output
EF Core 8.0.11, no IDesignTimeDbContextFactory - WORKS
EF Core 8.0.11, with IDesignTimeDbContextFactory - WORKS
EF Core 9.0.0, no IDesignTimeDbContextFactory - WORKS
EF Core 9.0.0, with IDesignTimeDbContextFactory - DOES NOT WORK
The text was updated successfully, but these errors were encountered: