Arebis.Core.Configuration.SqlServer 8.0.0

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

Arebis.Core.Configuration.SqlServer

A SQL server configuration source for .NET Core applications.

Configuration setup

Use the following code to add the SQL Server configuration provider:

builder.Configuration.AddSqlServer(builder.Configuration.GetConnectionString("DefaultConnection")!);

You can also specify the environment and refresh interval:

builder.Configuration.AddSqlServer(builder.Configuration.GetConnectionString("DefaultConnection")!, environment: "Production", refreshInterval: TimeSpan.FromSeconds(10));

If not specified, the environment is taken from the ASPNETCORE_ENVIRONMENT variable (or defaults to "Production" if not set), and no refreshes are performed.

Not that to use refreshed option values, you should use IOptionsSnapshot<T> or IOptionsMonitor<T> instead of IOptions<T>.

Database setup

Us the following script to create the required table:

IF NOT EXISTS (SELECT * FROM sys.schemas WHERE name = 'config')
BEGIN
    EXECUTE ('CREATE SCHEMA [config] AUTHORIZATION [dbo]')
END
GO

CREATE TABLE [config].[AppConfiguration]
(
    [Id] int IDENTITY(1,1) NOT NULL,
    [Key] nvarchar(200) NOT NULL,
    [Value] nvarchar(max) NULL,
    [Environment] nvarchar(100) NULL,
    CONSTRAINT [PK_AppConfiguration] PRIMARY KEY CLUSTERED ([Id] ASC)
) ON [PRIMARY]
GO

CREATE UNIQUE NONCLUSTERED INDEX [IX_AppConfiguration_Key_Environment] ON [config].[AppConfiguration] ([Key] ASC, [Environment] ASC)
GO

Configuring values

Insert configuration values into the table as follows:

INSERT INTO [config].[AppConfiguration] ([Key], [Value], [Environment])
VALUES ('MySection:MyKey', 'MyValue', 'Production');

A value of NULL in the Environment column indicates that the setting is for all environments (unless overwritten for a specific environment).

Use the colon (:) character to indicate sections and subsections.

Credits

Implementation is based on: https://mousavi310.github.io/posts/a-refreshable-sql-server-configuration-provider-for-net-core/.

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
8.0.0 393 1/19/2026