Skip to content

Multiple provider connection string support #286

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
parithon opened this issue Sep 8, 2018 · 0 comments
Open

Multiple provider connection string support #286

parithon opened this issue Sep 8, 2018 · 0 comments

Comments

@parithon
Copy link
Contributor

parithon commented Sep 8, 2018

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant