-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Closed
Description
Describe the bug
New web apps, apis and Blazor hosted applications created with the new templates do not use user's secrets set in secrets.json without manually adding:
builder.WebHost.ConfigureAppConfiguration((hostContext, builder) =>
{
if (hostContext.HostingEnvironment.IsDevelopment())
{
builder.AddUserSecrets<Program>();
}
});
after var builder = WebApplication.CreateBuilder(args);
.
To Reproduce
Create a new web application, web api or Blazor hosted application which uses EF Core, so it requires a connection string, as an example piece of information that may be stored in secrets.json. Set a connection string in secrets.json different from the default in appsettings.json. Execute Add-Migration and Update-Database in the package manager console. The connection string from appsettings will be used rather than the one from secrets.json.
Further technical details
- ASP.NET Core version: Net 6 RC1
- Include the output of
dotnet --info
:
.NET SDK (reflecting any global.json):
Version: 6.0.100-rc.1.21463.6
Commit: e627d556a1
Runtime Environment:
OS Name: Windows
OS Version: 10.0.19043
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\6.0.100-rc.1.21463.6\
- The IDE (VS / VS Code/ VS4Mac) you're running on, and its version: VS 2020 Preview 4.1 Community Edition (64 bit)
zHaytam, AlbertoPa, MariovanZeist and jtlowe