CoreWiki icon indicating copy to clipboard operation
CoreWiki copied to clipboard

Multiple provider connection string support

Open parithon opened this issue 7 years ago • 0 comments
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) ...

bitmoji

Edit: fixed a typo.

parithon avatar Sep 08 '18 06:09 parithon