CoreWiki
CoreWiki copied to clipboard
Multiple provider connection string support
trafficstars
Perhaps we could use the following convention for the connection strings to support multiple providers and connection strings within the appsettings.json?
appsettings.json
"ConnectionStrings": {
"CoreWikiIdentity": {
"": "./App_Data/wikiIdentity.db",
"postgres": "host=localhost;port=5432;user id=postgres;password=***"
},
"CoreWikiData": {
"": "./App_Data/wikiContent.db",
"postgres": "host=localhost;port=5432;user id=postgres;password=***"
}
}
Then we can use the following to get the connection strings:
StartupExtensions.cs
var provider = config["DataProvider"].ToLowerInvariant();
var connectionString = config.GetConnectionString($"CoreWikiData:{provider}");
switch (provider) ...
IdentityHostingStartup.cs
var provider = context.Configuration["DataProvider"].ToLowerInvariant();
var connectionString = config.GetConnectionString($"CoreWikiIdenity:{provider}");
switch (provider) ...

Edit: fixed a typo.