efcore icon indicating copy to clipboard operation
efcore copied to clipboard

Migration bundle only executes code in `Development` mode

Open aradalvand opened this issue 2 years ago • 3 comments

Using EF Core 7.0 with ASP.NET Core 7.0, running

dotnet ef migrations bundle --configuration Release

actually executes application code (specifically Program.cs until app.Build(), to build the DI container to then get an instance of DbContext) with builder.Environment.Name of Development, even though --configuration has been set to Release. This means that for example the right appsettings*.json file won't be read.

In fact, --configuration Release doesn't seem to have any effect whatsoever in the case of the ef migrations bundle command, am I missing something?

aradalvand avatar Dec 31 '22 04:12 aradalvand

/cc @bricelam

ajcvickers avatar Jan 03 '23 12:01 ajcvickers

I think you're trying to set the ASP.NET environment, not the build configuration:

dotnet ef migrations bundle -- --environment Production

bricelam avatar Jan 12 '23 22:01 bricelam

@bricelam Hi.

I can not understand what I'm doing wrong, everything seems to be done according to the instruction.

image

[Updates] Checked it now, it really works. thnx @bricelam

chertby avatar Jan 16 '23 14:01 chertby

We should consider #8695 when fixing this.

bricelam avatar Jan 27 '23 18:01 bricelam

Note, it might actually be using the Production environment. That message just means that it's setting ASPNETCORE_ENVIRONMENT to compensate for the lack of #8695.

bricelam avatar Jan 27 '23 18:01 bricelam