You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+48Lines changed: 48 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,6 +8,54 @@ A configuration provider that uses SQL Server as its backing store.
8
8
9
9
---
10
10
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
+
awaitHost.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.
options.ConnectionString??thrownewSqlServerConfigurationProviderException("Cannot build a SQL Server Configuration Provider without a connection string."),
25
+
TimeSpan.FromSeconds(options.RefreshSeconds),
26
+
options.SchemaName??thrownewSqlServerConfigurationProviderException("The schema name is required to use SQL Server Configuration."),
27
+
options.TableName??thrownewSqlServerConfigurationProviderException("The table name is required to use SQL Server Configuration."));
0 commit comments