csharpfritz / csharpfritz/CoreWiki

Multiple provider connection string support

Open
#286 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
CSS
Stars
438
Forks
159
PR merge metrics
No merged PRs in 30d

Description

Perhaps we could use the following convention for the connection strings to support multiple providers and connection strings within the appsettings.json?

**appsettings.json**
```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**
```c#
var provider = config["DataProvider"].ToLowerInvariant();
var connectionString = config.GetConnectionString($"CoreWikiData:{provider}");

switch (provider) ...
```

**IdentityHostingStartup.cs**
```c#
var provider = context.Configuration["DataProvider"].ToLowerInvariant();
var connectionString = config.GetConnectionString($"CoreWikiIdenity:{provider}");

switch (provider) ...
```

![bitmoji](https://render.bitstrips.com/v2/cpanel/3cef88b0-5464-469b-a5d3-ffe6f33649d4-5ce1021d-68dc-49f1-88ed-492d21ac8aab-v1.png?transparent=1&palette=1&width=246)

Edit: fixed a typo.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.