My suggestion would be to add the appropriate connection strings to appsettings.json
so that the last lines read something like this
"AllowedHosts": "*",
"ConnectionStrings": {
"CustomerOneConnection": "Data Source=(localdb)\\ProjectModels;Initial Catalog=Northwind;Integrated Security=True",
"CustomerTwoConnection": "Data Source=(localdb)\\ProjectModels;Initial Catalog=Southwind;Integrated Security=True"
}
Use a class to bind the connections to the public properties of the class. The names must exactly match the connection string names.
public class ServerOptions
{
public const string ConnectionStrings = "ConnectionStrings";
public string CustomerOneConnection { get; set; } = string.Empty;
public string CustomerTwoConnection { get; set; } = string.Empty;
}
Now you can bind the connection strings to the 2 public properties like this
var serverOptions = new ServerOptions();
Configuration.GetSection(ServerOptions.ConnectionStrings).Bind(serverOptions);