ConfigurationRepository 1.1.1

dotnet add package ConfigurationRepository --version 1.1.1
                    
NuGet\Install-Package ConfigurationRepository -Version 1.1.1
                    
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="ConfigurationRepository" Version="1.1.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ConfigurationRepository" Version="1.1.1" />
                    
Directory.Packages.props
<PackageReference Include="ConfigurationRepository" />
                    
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 ConfigurationRepository --version 1.1.1
                    
#r "nuget: ConfigurationRepository, 1.1.1"
                    
#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.
#addin nuget:?package=ConfigurationRepository&version=1.1.1
                    
Install as a Cake Addin
#tool nuget:?package=ConfigurationRepository&version=1.1.1
                    
Install as a Cake Tool

ConfigurationRepository

An ASP .NET Core class library that provides access to application`s configuration stored in a database or any other repository.

NuGet NuGet

Installation:

  • from NuGet;
  • from package manager console:
Install-Package ConfigurationRepository
  • from command line:
dotnet add package ConfigurationRepository

Usage:

The configuration can be stored in two different structured forms, we have to choose one:

  • A single configuration with it`s keys and values, like in a dictionary. This type of configuration repository is called Dictionary repository.
  • Multiple configurations, one of which is extracted using the Key and a Value that contains parsable hierarchical structure of the configuration by that Key. This type of configuration repository is called Parsable repository.

Currently, the only format supported for Parsable repository is in JSON format. This can be easily extended implementing IConfigurationParser interface for any format needed.

A dictionary repository provider is registered by AddDictionaryRepository() extension method called on configuration builder.

A parsable repository provider is registered by AddParsableRepository() extension method called on configuration builder.

Examples:

Here is a simple example with two in-memory repositories:

  • A dictionary repository that stores it`s data as key-value pairs.
  • A parsable repository that is stored as a string parsed into a JSON.
using ConfigurationRepository;

var builder = WebApplication.CreateBuilder(args);

// Define our sample data for dictionary repository.
var configDictData = new Dictionary<string, string?>(StringComparer.OrdinalIgnoreCase)
{ { "DICT KEY", "DICT VALUE" } };

// Define our sample data for json repository.
var configJsonData = """{"JSON KEY":"JSON VALUE"}""";

// Add our two configuration repository providers with different
// repositories to configuration builder.
builder.Configuration
    .AddDictionaryRepository(new InMemoryDictionaryRepository(configDictData))
    .AddParsableRepository(new InMemoryJsonRepository(configJsonData));

var app = builder.Build();

app.Run();

// A dictionary in-memory repository.
class InMemoryDictionaryRepository(IDictionary<string, string?> configData)
    : IConfigurationRepository
{
    public TData GetConfiguration<TData>()
    {
        return (TData)configData;
    }
}

// A parsable json in-memory repository.
class InMemoryJsonRepository(string jsonConfig)
    : IConfigurationRepository
{
    public TData GetConfiguration<TData>()
    {
        return (TData)Convert.ChangeType(jsonConfig, typeof(TData));
    }
}

More complex example with database-stored configuration repository that stores secrets separatley in Vault and parametrizes this configuration with these secret values you may find in ConfigurationRepository.VaultWithDbWebApp sample project on github. Note that It uses docker and docker-compose to set all environment up.

See also:

The main purpose of ConfigurationRepository is to store the configuration in a database. The following libraries provide this:

ConfigurationRepository.Dapper - for accessing database configurations using Dapper ORM.

ConfigurationRepository.EntityFramework - for accessing database configurations using Entity Frameworks ORM.

ConfigurationRepository.SqlClient - for accessing MS SQL Server database configurations using MS SqlClient library.

Any of these configurations may also be parametrizable:

ParametrizedConfiguration - for parametrizing configuration provided by other configuration providers.

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 (3)

Showing the top 3 NuGet packages that depend on ConfigurationRepository:

Package Downloads
ConfigurationRepository.Dapper

Configuration repository provider that stored in a database and accessed via Dapper ORM.

ConfigurationRepository.EntityFramework

Configuration repository provider that stored in a database and accessed via EfCore ORM.

ConfigurationRepository.SqlClient

Configuration repository provider that stored in an MS SQL Server database and accessed via SqlClient library.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.1.1 122 7/1/2025
1.1.0 126 6/29/2025
1.0.0 156 6/16/2025