Skip to content

Commit 16ae2b6

Browse files
(#10) Mark off from check list
1 parent baf3d43 commit 16ae2b6

File tree

3 files changed

+49
-1
lines changed

3 files changed

+49
-1
lines changed

README.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,54 @@ A configuration provider that uses SQL Server as its backing store.
88

99
---
1010

11+
## Set up
12+
13+
The simplest way is to configure the SQL Server configuration from the existing configuration up to that point. Any configuration providers added after the call to `AddSqlServer` will not have their data alter the way that the SQL Server configuration provider is set up.
14+
15+
```csharp
16+
await Host.CreateDefaultBuilder(args)
17+
.ConfigureAppConfiguration(builder =>
18+
{
19+
builder.AddSqlServer(opts =>
20+
{
21+
// Will pull connection string, schema and table names from the
22+
// configuration system up to this point.
23+
opts.FromExistingConfiguration();
24+
});
25+
})
26+
```
27+
28+
with the corresponding information in `appsettings.json`, e.g.:
29+
30+
```json
31+
{
32+
"ConnectionStrings": {
33+
"ConfigDB": "*** Found in Secret Store ***"
34+
},
35+
"Stravaig": {
36+
"AppConfiguration": {
37+
"SchemaName": "Stravaig",
38+
"TableName": "AppConfiguration",
39+
"RefreshSeconds": 90,
40+
"ConnectionStringName": "ConfigDB"
41+
}
42+
}
43+
}
44+
```
45+
46+
The default configuration section used is `Stravaig.AppSettings`, however, this can be changed to what ever you prefer by passing in the path to the configuration section you prefer. e.g.
47+
48+
```csharp
49+
builder.AddSqlServer(opts =>
50+
{
51+
// Will pull connection string, schema and table names from the
52+
// configuration system at the specified config section.
53+
opts.FromExistingConfiguration("MyApp:SqlConfiguration");
54+
});
55+
```
56+
57+
58+
1159
## Contributing / Getting Started
1260

1361
* Ensure you have PowerShell 7.1.x or higher installed

src/Stravaig.Configuration.SqlServer.Tests/SourceBuilderTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ public void TwoCompetingConnectionStrings_DirectOneWins()
210210
source.TableName.ShouldBe(tableName);
211211
}
212212

213-
private IConfigurationBuilder SetupConfig(Action<IConfigurationBuilder> configure = null)
213+
private IConfigurationBuilder SetupConfig(Action<IConfigurationBuilder>? configure = null)
214214
{
215215
var builder = new ConfigurationBuilder();
216216
configure?.Invoke(builder);

0 commit comments

Comments
 (0)