I am running a .net core 2.1 application on a mac and I am trying to access my connections string which should be overridden by my user secrets. The .csproj file includes a guid
<UserSecretsId>{{Secret Guid}}</UserSecretsId>
Add the user secret keys
dotnet user-secrets set "ConnectionStrings:DefaultConnection" "Secret Connection String"
I create the configuration which reads from my appsettings.json file perfectly however it does not replaces the default values with the ones from my user secrets.
// this is done so I build my configurations in a class library
var assembly = AppDomain.CurrentDomain.GetAssemblies()
.Single(o => o.EntryPoint != null);
var configurationBuilder = new ConfigurationBuilder()
.AddEnvironmentVariables()
// .AddUserSecrets<Program>() -> This does not work either
.AddUserSecrets(assembly, optional: false);
configurationBuilder.SetBasePath(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location));
configurationBuilder.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true);
var configuration = configurationBuilder.Build();
Console.WriteLine(configuration["ConnectionStrings:DefaultConnection"]);
As I stated previously trying to access the values it does not replace the values with the user secrets values. Please let me know what I am missing.