csharpfritz / csharpfritz/CoreWiki
Multiple provider connection string support
- 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) ...
```

Edit: fixed a typo.
Contributor guide
Assessment
This issue has not been assessed yet.