| .github/workflows | ||
| .idea/.idea.SS14.ConfigProvider/.idea | ||
| SS14.ConfigProvider | ||
| SS14.ConfigProvider.Tests | ||
| .gitignore | ||
| icon.png | ||
| LICENSE.txt | ||
| README.md | ||
| SS14.ConfigProvider.sln | ||
SS14.ConfigProvider
A configuration provider implementation for Microsoft.Extensions.Configuration providing configuration values from a configurable EfCore data source.
Usage
To use the configuration provider you need to use the AddConfigurationDb.
It takes a DbContext implementing IConfigurationDbContext as a type parameter. You need to use the callback parameter to configure a DbContextOptionsBuilder to use the correct database.
// Example using an in memory database
builder.Configuration.AddConfigurationDb<TestContext>(b => b.UseInMemoryDatabase("TestDb"));
Storing values
The configuration provider stores values in a table called ConfigurationStore.
To store a value, you need to use the ConfigurationStore entity. This package doesn't provide its own way of setting
values in the database. You need to use EfCore for that.
Working with dynamic configuration values
Using IConfiguration.Bind works for when you call Bind every time you want to get a configuration value.
A smarter approach is to use IOptionsSnapshot<T> to get a snapshot of the configuration values in scoped services
IOptionsMonitor for singleton services or when you need a delegate that gets called on configuration updates.
For more information see the Microsoft documentation about the options pattern.