Skip to content

Instantly share code, notes, and snippets.

@ErikNoren
ErikNoren / Program.cs
Last active February 27, 2024 18:15
ASP.NET Core 6 configuration settings stored in a SQL database and acts just like appsettings.json
//Snippet from Program.cs which adds the provider and sets up a Settings class to map the settings
using ErikNoren.Configuration;
using TestMvcWebApplication;
var builder = WebApplication.CreateBuilder(args);
builder.Configuration.AddSqlDatabase(config =>
{
//We can get the connection string from previously added ConfigurationProviders to use in setting this up
config.ConnectionString = builder.Configuration.GetConnectionString("DemoDatabase");