Mirror of space-wizards/ConfigProvider
Find a file
2025-05-03 08:50:23 +02:00
.github/workflows Fix publish workflow (Hopefully) 2025-05-01 15:42:29 +02:00
.idea/.idea.SS14.ConfigProvider/.idea Initial commit 2024-08-16 16:16:49 +02:00
SS14.ConfigProvider fix: UpdatedOn Column not having a value. 2025-05-03 08:50:23 +02:00
SS14.ConfigProvider.Tests Update to .net 9 2025-04-17 15:35:22 +02:00
.gitignore Add rider user settings to gitignore 2025-04-17 15:42:21 +02:00
icon.png Fix gh workflow 2025-04-17 17:33:39 +02:00
LICENSE.txt Fix gh workflow 2025-04-17 17:33:39 +02:00
README.md Fix gh workflow 2025-04-17 17:33:39 +02:00
SS14.ConfigProvider.sln Initial commit 2024-08-16 16:16:49 +02:00

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.