Skip to content

Instantly share code, notes, and snippets.

@CoreProgramm
Created April 12, 2020 07:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CoreProgramm/382f86066da4a58ecdf3c968b29d8763 to your computer and use it in GitHub Desktop.
Save CoreProgramm/382f86066da4a58ecdf3c968b29d8763 to your computer and use it in GitHub Desktop.
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