Try my NuGet package ConfigurationLibrary created in .NET Core 5, works with .NET Core 6. Why three environments, because it's good practice, for you just use the one.
{
"ConnectionsConfiguration": {
"ActiveEnvironment": "Development",
"Development": "Data Source=q:\\data\\SeguroMedicoMFC.sqlite;",
"Stage": "Stage connection string goes here",
"Production": "Prod connection string goes here"
}
}
Then in the DbContext, add a using statement using ConfigurationLibrary.Classes;
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
if (!optionsBuilder.IsConfigured)
{
optionsBuilder.UseSqlite(ConfigurationHelper.ConnectionString());
}
}
Place an appsettings.json file in the root folder of the project, set copy if newer.