Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Dynamically read connection string in ASP .NET Core
public IConfigurationRoot ConfigurationRoot { get; set; }
public static string ConnectionString { get; private set; }
public Startup(IConfiguration config,IWebHostEnvironment env)
{
ConfigurationRoot = new ConfigurationBuilder()
.SetBasePath(env.ContentRootPath)
.AddJsonFile("appSettings.json")
.Build();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.