Ling.Configuration.Database 0.1.0

dotnet add package Ling.Configuration.Database --version 0.1.0
                    
NuGet\Install-Package Ling.Configuration.Database -Version 0.1.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Ling.Configuration.Database" Version="0.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Ling.Configuration.Database" Version="0.1.0" />
                    
Directory.Packages.props
<PackageReference Include="Ling.Configuration.Database" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Ling.Configuration.Database --version 0.1.0
                    
#r "nuget: Ling.Configuration.Database, 0.1.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Ling.Configuration.Database@0.1.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Ling.Configuration.Database&version=0.1.0
                    
Install as a Cake Addin
#tool nuget:?package=Ling.Configuration.Database&version=0.1.0
                    
Install as a Cake Tool

Ling.Configuration.Database

English | 简体中文

Build NuGet

An ADO.NET backed Microsoft.Extensions.Configuration provider with polling reload support. It is distributed as one package; install the ADO.NET driver you want to use separately.

Install

dotnet add package Ling.Configuration.Database
dotnet add package Microsoft.Data.Sqlite

Usage

Read the bootstrap connection string before adding the database source. It is captured when AddDatabase is called, so a value loaded from the database cannot change the connection used by this provider.

{
  "ConnectionStrings": {
    "ConfigurationDatabase": "Data Source=configuration.db"
  }
}
using Ling.Configuration.Database;
using Microsoft.Data.Sqlite;

var connectionString = builder.Configuration.GetConnectionString("ConfigurationDatabase")!;
builder.Configuration.AddDatabase(connectionString, SqliteFactory.Instance, options =>
{
    options.PollingInterval = TimeSpan.FromSeconds(30);
    options.TableName = "ConfigurationEntries";
    options.Decryptor = entry => Decrypt(entry.Value!);
});

setupAction is optional. The default query reads ConfigKey, ConfigValue, and IsEncrypted from ConfigurationEntries. ConfigKey must be non-empty and unique without regard to case. ConfigValue may be null. Set EncryptionColumnName = null when the table has no encryption marker column. Identifiers allow letters, digits, and underscores by default; configure IdentifierQuoter for provider-specific quoting.

The driver package supplies the DbProviderFactory. For SQL Server or PostgreSQL, install the corresponding driver and pass its factory with the connection string.

For a custom query, tenant filter, or nonstandard schema, implement IDatabaseConfigurationLoader and pass it to the AddDatabase(loader, setupAction) overload. The same snapshot validation, decryption, polling, and reload behavior applies.

Encrypted values

Set IsEncrypted to true for rows that contain ciphertext. The optional Decryptor runs only for those rows. If it is missing or throws, the error is logged and the original stored value is used. Set DatabaseConfigurationOptions.Logger to use the application's logger; otherwise the error is written through System.Diagnostics.Trace.

Reload behavior

The provider loads a complete snapshot when configuration is built, then polls every 30 seconds by default. It compares keys without regard to case and compares values ordinally. It updates the snapshot and triggers the standard reload token only when a key is added, removed, or changed. A failed poll keeps the last successful snapshot and later polls continue. Polls run serially.

Add the provider after JSON sources. Environment variables and command-line arguments keep their normal higher priority. IOptionsMonitor<T> and services that read the injected IConfiguration again can observe updates. A regular value read once during service registration is a one-time snapshot.

Schema example

CREATE TABLE ConfigurationEntries (
    ConfigKey TEXT NOT NULL PRIMARY KEY,
    ConfigValue TEXT NULL,
    IsEncrypted INTEGER NOT NULL DEFAULT 0
);

Adapt the types to the selected database. The library does not create or migrate this table; manage its schema with your database's usual migration mechanism.

Sample

SQLite sample creates a local database table, loads a sample value, and demonstrates options reload.

dotnet run --project samples/Ling.Configuration.Database.Sample

License

This project is licensed under the MIT License.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.1.0 39 10/8/2026
0.1.0-preview.1 53 9/29/2026