DotNetBrightener.SiteSettings 2026.0.1-preview-notification-service-698

This is a prerelease version of DotNetBrightener.SiteSettings.
dotnet add package DotNetBrightener.SiteSettings --version 2026.0.1-preview-notification-service-698
                    
NuGet\Install-Package DotNetBrightener.SiteSettings -Version 2026.0.1-preview-notification-service-698
                    
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="DotNetBrightener.SiteSettings" Version="2026.0.1-preview-notification-service-698" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="DotNetBrightener.SiteSettings" Version="2026.0.1-preview-notification-service-698" />
                    
Directory.Packages.props
<PackageReference Include="DotNetBrightener.SiteSettings" />
                    
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 DotNetBrightener.SiteSettings --version 2026.0.1-preview-notification-service-698
                    
#r "nuget: DotNetBrightener.SiteSettings, 2026.0.1-preview-notification-service-698"
                    
#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 DotNetBrightener.SiteSettings@2026.0.1-preview-notification-service-698
                    
#: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=DotNetBrightener.SiteSettings&version=2026.0.1-preview-notification-service-698&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=DotNetBrightener.SiteSettings&version=2026.0.1-preview-notification-service-698&prerelease
                    
Install as a Cake Tool

DotNetBrightener SiteSettings Module

Overview

The DotNetBrightener SiteSettings module provides a comprehensive solution for managing application-wide configuration settings in .NET applications. It offers a flexible, type-safe approach to storing and retrieving settings with built-in caching, database persistence, and RESTful API endpoints.

Key Features

  • Type-safe settings management with strongly-typed setting classes
  • Database persistence with support for SQL Server and PostgreSQL
  • Built-in caching for optimal performance
  • RESTful API endpoints for CRUD operations
  • Automatic database migrations and schema management
  • Localization support for error messages and descriptions
  • Audit trail with creation/modification tracking
  • Default value merging for backward compatibility

Architecture

The module follows a layered architecture:

  • Controllers: RESTful API endpoints (SiteSettingsController)
  • Services: Business logic (ISiteSettingService, SiteSettingService)
  • Data Access: Repository pattern (ISiteSettingDataService)
  • Models: Setting definitions (SiteSettingBase, SiteSettingWrapper<T>)
  • Storage: Database-specific implementations (SQL Server, PostgreSQL)

Required Dependencies

Core NuGet Packages

<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.7" />
<PackageReference Include="Microsoft.Extensions.Localization" Version="9.0.7" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />

Database-Specific Packages

For SQL Server:

<PackageReference Include="DotNetBrightener.SiteSettings.Data.Mssql" Version="[latest]" />

For PostgreSQL:

<PackageReference Include="DotNetBrightener.SiteSettings.Data.PostgreSql" Version="[latest]" />

Framework Dependencies

  • DotNetBrightener.Caching.Abstractions: For caching functionality
  • DotNetBrightener.DataAccess.Abstractions: For data access patterns

Integration Steps

Step 1: Install Required Packages

# Core package
dotnet add package DotNetBrightener.SiteSettings

# Choose your database provider
dotnet add package DotNetBrightener.SiteSettings.Data.Mssql
# OR
dotnet add package DotNetBrightener.SiteSettings.Data.PostgreSql

Step 2: Define Your Settings Classes

Create strongly-typed setting classes by inheriting from SiteSettingWrapper<T>:

using DotNetBrightener.SiteSettings.Models;

public class ApplicationSettings : SiteSettingWrapper<ApplicationSettings>
{
    public string ApplicationName { get; set; } = "My Application";
    public string SupportEmail { get; set; } = "support@example.com";
    public int MaxFileUploadSize { get; set; } = 10485760; // 10MB
    public bool EnableNotifications { get; set; } = true;

    public override string SettingName => "Application Settings";
    public override string Description => "General application configuration settings";
}

public class EmailSettings : SiteSettingWrapper<EmailSettings>
{
    public string SmtpServer { get; set; } = "localhost";
    public int SmtpPort { get; set; } = 587;
    public string Username { get; set; }
    public string Password { get; set; }
    public bool EnableSsl { get; set; } = true;

    public override string SettingName => "Email Settings";
    public override string Description => "SMTP configuration for email sending";
}

Step 3: Configure Services in Program.cs

using DotNetBrightener.SiteSettings;
using DotNetBrightener.SiteSettings.Extensions;

var builder = WebApplication.CreateBuilder(args);

// Add localization support
builder.Services.AddLocalization();

// Add MVC services
var mvcBuilder = builder.Services.AddControllersWithViews();

// Register SiteSettings API
mvcBuilder.RegisterSiteSettingApi();

// Configure database storage (choose one)
// For SQL Server:
builder.Services.AddSiteSettingsSqlServerStorage(
    builder.Configuration.GetConnectionString("DefaultConnection"));

// For PostgreSQL:
// builder.Services.AddSiteSettingsPostgreSqlStorage(
//     builder.Configuration.GetConnectionString("DefaultConnection"));

// Register your setting types
builder.Services.RegisterSettingType<ApplicationSettings>();
builder.Services.RegisterSettingType<EmailSettings>();

var app = builder.Build();

// Configure the HTTP request pipeline
app.MapControllers();

app.Run();

Step 4: Database Configuration

Add connection string to appsettings.json:

{
  "ConnectionStrings": {
    "DefaultConnection": "Server=localhost;Database=MyApp;Trusted_Connection=true;TrustServerCertificate=true;"
  }
}

The module will automatically create the required database schema and tables on first run.

API Endpoints

The module exposes the following RESTful endpoints:

Get All Available Settings

GET /api/SiteSettings/allSettings

Response:

[
  {
    "settingName": "Application Settings",
    "description": "General application configuration settings",
    "settingType": "MyApp.ApplicationSettings"
  }
]

Get Setting Values

GET /api/SiteSettings/{settingKey}

Example:

GET /api/SiteSettings/MyApp.ApplicationSettings

Response:

{
  "applicationName": "My Application",
  "supportEmail": "support@example.com",
  "maxFileUploadSize": 10485760,
  "enableNotifications": true
}

Get Default Setting Values

GET /api/SiteSettings/{settingKey}/default

Save Setting Values

POST /api/SiteSettings/{settingKey}
Content-Type: application/json

{
  "applicationName": "Updated App Name",
  "supportEmail": "newsupport@example.com",
  "maxFileUploadSize": 20971520,
  "enableNotifications": false
}

Programmatic Usage

Inject and Use Settings Service

using DotNetBrightener.SiteSettings.Abstractions;

[ApiController]
[Route("api/[controller]")]
public class MyController : ControllerBase
{
    private readonly ISiteSettingService _settingService;

    public MyController(ISiteSettingService settingService)
    {
        _settingService = settingService;
    }

    [HttpGet("app-info")]
    public IActionResult GetAppInfo()
    {
        var appSettings = _settingService.GetSetting<ApplicationSettings>();
        
        return Ok(new
        {
            Name = appSettings.ApplicationName,
            Support = appSettings.SupportEmail,
            MaxUpload = appSettings.MaxFileUploadSize
        });
    }

    [HttpPost("update-settings")]
    public IActionResult UpdateSettings([FromBody] ApplicationSettings settings)
    {
        _settingService.SaveSetting(settings);
        return Ok();
    }
}

Configuration Options

Caching Configuration

The module uses the DotNetBrightener caching system. Settings are cached for 10 minutes by default. Configure caching in your startup:

// Add memory caching
builder.Services.AddMemoryCache();

// Or Redis caching
builder.Services.AddStackExchangeRedisCache(options =>
{
    options.Configuration = "localhost:6379";
});

Database Schema

The module creates tables in the following schema:

SQL Server: SiteSettings.SiteSettingRecord PostgreSQL: site_settings.site_setting_record

Table Structure:

  • Id (bigint, primary key)
  • SettingType (nvarchar(1024)) - Fully qualified type name
  • SettingContent (nvarchar(max)) - JSON serialized settings
  • Audit fields: CreatedDate, CreatedBy, ModifiedDate, ModifiedBy
  • Soft delete fields: IsDeleted, DeletedDate, DeletedBy, DeletionReason

Error Handling

The module provides localized error messages. Common error scenarios:

Setting Type Not Found

{
  "errorMessage": "Setting 'InvalidType' not found"
}

Invalid Setting Type

{
  "errorMessage": "Setting type must inherit from SiteSettingBase"
}

Advanced Features

Custom Contract Resolver

The module uses a custom JSON contract resolver (SiteSettingsContractResolver) for consistent serialization.

Default Value Merging

When retrieving settings, the module automatically merges saved values with default values, ensuring backward compatibility when new properties are added to setting classes.

Audit Trail

All setting changes are automatically tracked with creation and modification timestamps and user information.

Testing

Unit Testing Example

[Test]
public void Should_Save_And_Retrieve_Settings()
{
    // Arrange
    var settings = new ApplicationSettings
    {
        ApplicationName = "Test App",
        SupportEmail = "test@example.com"
    };

    // Act
    _settingService.SaveSetting(settings);
    var retrieved = _settingService.GetSetting<ApplicationSettings>();

    // Assert
    Assert.AreEqual("Test App", retrieved.ApplicationName);
    Assert.AreEqual("test@example.com", retrieved.SupportEmail);
}

Troubleshooting

Common Issues

  1. Database Connection Issues

    • Verify connection string format
    • Ensure database server is accessible
    • Check firewall settings
  2. Migration Issues

    • Ensure proper permissions for schema creation
    • Check if migrations are enabled in configuration
  3. Caching Issues

    • Verify caching service is properly registered
    • Check cache key conflicts
  4. Serialization Issues

    • Ensure setting properties have public getters/setters
    • Avoid circular references in setting objects

Performance Considerations

  • Settings are cached for 10 minutes by default
  • Use appropriate database indexes for SettingType column
  • Consider using Redis for distributed caching in multi-instance deployments

Migration from Other Configuration Systems

From appsettings.json

  1. Create setting classes for your configuration sections
  2. Register setting types in DI container
  3. Migrate values using the API or programmatically
  4. Update code to use ISiteSettingService instead of IConfiguration

From Custom Configuration Tables

  1. Create migration scripts to transform existing data
  2. Map existing columns to setting class properties
  3. Use the SaveSetting method to populate the new system

This integration guide provides everything needed to successfully implement the DotNetBrightener SiteSettings module in your .NET applications.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  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 (2)

Showing the top 2 NuGet packages that depend on DotNetBrightener.SiteSettings:

Package Downloads
DotNetBrightener.SiteSettings.Data.Mssql

Package Description

DotNetBrightener.SiteSettings.Data.PostgreSql

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2026.0.1-preview-notificati... 29 12/7/2025
2026.0.1-preview-notificati... 45 12/6/2025
2026.0.1-preview-net10-upgr... 185 11/25/2025
2026.0.1-preview-net10-upgr... 177 11/25/2025
2026.0.1-preview-net10-upgr... 179 11/25/2025
2026.0.1-preview-net10-upgr... 187 11/24/2025
2026.0.1-preview-net10-upgr... 209 11/24/2025
2026.0.1-preview-migrate-to... 61 12/6/2025
2026.0.1-preview-700 40 12/7/2025
2026.0.1-preview-689 49 12/6/2025
2026.0.1-preview-676 630 12/2/2025
2026.0.1-preview-671 123 11/29/2025
2026.0.1-preview-670 109 11/29/2025
2026.0.1-preview-669 110 11/29/2025
2026.0.1-preview-667 172 11/27/2025
2026.0.1-preview-665 172 11/27/2025
2026.0.1-preview-664 172 11/27/2025
2026.0.1-preview-660 177 11/25/2025
2025.0.10 194 11/25/2025
2025.0.10-preview-628 416 11/20/2025
2025.0.10-preview-605 284 11/17/2025
2025.0.10-preview-602 288 11/17/2025
2025.0.10-preview-581 305 11/11/2025
2025.0.10-preview-559 201 10/29/2025
2025.0.10-preview-557 198 10/27/2025
2025.0.9 198 10/26/2025
2025.0.9-preview-553 193 10/26/2025
2025.0.9-preview-539 129 10/12/2025
2025.0.9-preview-535 191 10/8/2025
2025.0.9-preview-509 212 10/2/2025
2025.0.9-preview-508 190 10/2/2025
2025.0.9-preview-487 207 9/29/2025
2025.0.9-preview-481 193 9/29/2025
2025.0.9-preview-473 173 9/28/2025
2025.0.8 214 9/23/2025
2025.0.6 212 9/22/2025
2025.0.6-preview-455 200 9/22/2025
2025.0.6-preview-454 323 9/17/2025
2025.0.6-preview-441 155 9/14/2025
2025.0.6-preview-440 158 9/14/2025
2025.0.6-preview-406 197 9/2/2025
2025.0.6-preview-401 179 9/2/2025
2025.0.6-preview-400 180 9/2/2025
2025.0.6-preview-369 238 8/27/2025
2025.0.6-preview-368 221 8/27/2025
2025.0.6-preview-334 211 8/18/2025
2025.0.6-preview-333 183 7/27/2025
2025.0.6-preview-332 515 7/24/2025
2025.0.6-preview-331 512 7/24/2025
2025.0.6-preview-328 505 7/24/2025
2025.0.6-preview-327 358 7/21/2025
2025.0.6-preview-326 367 7/21/2025
2025.0.6-preview-325 300 7/20/2025
2025.0.6-preview-324 273 7/20/2025
2025.0.6-preview-322 280 7/20/2025
2025.0.6-preview-321 271 7/19/2025
2025.0.6-preview-320 277 7/19/2025
2025.0.6-preview-319 192 7/17/2025
2025.0.6-preview-317 181 7/17/2025
2025.0.6-preview-316 179 7/17/2025
2025.0.6-preview-315 176 7/17/2025
2025.0.6-preview-314 176 7/17/2025
2025.0.6-preview-313 186 7/17/2025
2025.0.6-preview-312 186 7/16/2025
2025.0.5 223 7/10/2025
2025.0.5-preview-307 135 7/5/2025
2025.0.4 136 7/5/2025
2025.0.4-preview-305 127 7/4/2025
2025.0.4-preview-304 188 7/1/2025
2025.0.4-preview-299 174 5/31/2025
2025.0.4-preview-298 147 5/30/2025
2025.0.4-preview-296 181 5/30/2025
2025.0.4-preview-295 194 5/29/2025
2025.0.4-preview-293 181 5/26/2025
2025.0.4-preview-292 192 5/26/2025
2025.0.3 187 2/10/2025
2025.0.3-preview-288 145 2/10/2025
2025.0.2 183 1/21/2025
2025.0.2-preview-278 121 1/21/2025
2025.0.2-preview-277 139 12/16/2024
2025.0.1-rc-243301701 394 11/25/2024
2024.0.14.6 191 11/25/2024
2024.0.14.6-rc-243031001 216 10/29/2024
2024.0.14.6-rc-243030701 148 10/29/2024
2024.0.14.6-rc-242840501 160 10/10/2024
2024.0.14.6-rc-242820305 136 10/8/2024
2024.0.14.6-rc-242771401 239 10/3/2024
2024.0.14.6-rc-242770501 123 10/3/2024
2024.0.14.6-rc-242770201 168 10/3/2024
2024.0.14.6-rc-242761801 142 10/2/2024
2024.0.14.6-rc-242761601 153 10/2/2024
2024.0.14.6-rc-242761501 144 10/2/2024
2024.0.14.6-rc-242761401 155 10/2/2024
2024.0.14.6-rc-242760701 154 10/2/2024
2024.0.14.6-rc-242751002 139 10/1/2024
2024.0.14.6-rc-242750901 161 10/1/2024
2024.0.14.6-rc-242750502 138 10/1/2024
2024.0.14.6-rc-242750201 147 10/1/2024
2024.0.14.6-rc-242741501 135 9/30/2024
2024.0.14.6-rc-242730701 177 9/29/2024
2024.0.14.6-preview-2730501 154 9/29/2024
2024.0.14.6-preview-2701501 174 9/26/2024
2024.0.14.6-preview-2620901 185 9/18/2024
2024.0.14.6-preview-2570701 163 9/13/2024
2024.0.14.6-preview-2510703 217 9/7/2024
2024.0.14.6-preview-2480501 174 9/4/2024
2024.0.14.6-preview-2430401 182 8/30/2024
2024.0.14.6-preview-242730701 151 9/29/2024
2024.0.14.6-preview-2421703 150 8/29/2024
2024.0.14.6-preview-2421701 142 8/29/2024
2024.0.14.6-preview-2420901 139 8/29/2024
2024.0.14.6-preview-2390101 173 8/26/2024
2024.0.14.6-preview-2381603 169 8/25/2024
2024.0.14.6-preview-2341601 206 8/21/2024
2024.0.14.6-preview-2321602 179 8/20/2024
2024.0.14.6-preview-2190801 206 8/6/2024
2024.0.14.6-preview-2041501 155 7/22/2024
2024.0.14.6-preview-1920603 222 7/10/2024
2024.0.14.6-preview-1920301 162 7/10/2024
2024.0.14.6-preview-1911302 168 7/9/2024
2024.0.14.6-preview-1901001 185 7/8/2024
2024.0.14.6-preview-1900901 176 7/8/2024
2024.0.14.6-preview-1900801 159 7/8/2024
2024.0.14.6-preview-1860304 156 7/4/2024
2024.0.14.5 247 7/1/2024
2024.0.14.5-preview-1811601 149 6/29/2024
2024.0.14.5-preview-1810501 198 6/29/2024
2024.0.14.5-preview-180132 167 6/28/2024
2024.0.14.5-preview-180131 179 6/28/2024
2024.0.14.5-preview-180121 158 6/28/2024
2024.0.14.4 208 6/27/2024
2024.0.14.4-preview-7 160 6/27/2024
2024.0.14.3 209 6/21/2024
2024.0.14.1 210 6/6/2024
2024.0.14.1-preview 146 6/6/2024
2024.0.14-preview-1 160 6/6/2024
2024.0.13.8-preview 157 6/6/2024
2024.0.13.1-preview-0146 139 6/6/2024
2024.0.12.15803-preview-03 124 6/6/2024
2024.0.12.15608 198 6/4/2024
2024.0.12.15515 271 6/3/2024
2024.0.12.15220 182 5/31/2024
2024.0.12.15220-alpha31-240... 151 5/31/2024
2024.0.12.14911 238 5/28/2024
2024.0.12.14910-alpha28-240... 163 5/28/2024
2024.0.12.14823 203 5/27/2024
2024.0.12.14522-alpha7-2405... 167 5/24/2024
2024.0.12.14514-alpha6-2405... 160 5/24/2024
2024.0.12.14511 208 5/24/2024
2024.0.12.14314 246 5/22/2024
2024.0.12.14114 240 5/20/2024
2024.0.12.12815 234 5/7/2024
2024.0.12.12814 197 5/7/2024
2024.0.12.12721 244 5/6/2024
2024.0.12.12702 233 5/5/2024
2024.0.12.12622 241 5/5/2024
2024.0.12.12514 230 5/4/2024
2024.0.12.12512 229 5/4/2024
2024.0.12.12510 221 5/4/2024
2024.0.12.12420 203 5/3/2024
2024.0.12.12319 165 5/2/2024
2024.0.12.12319-rc-2405021801 138 5/2/2024
2024.0.12.12318 189 5/2/2024
2024.0.12.12215 198 5/1/2024
2024.0.12.12011 196 4/29/2024
2024.0.12.11720 202 4/26/2024
2024.0.12.11719 197 4/26/2024
2024.0.12.11621 207 4/25/2024
2024.0.12.11523 190 4/24/2024
2024.0.12.11522 199 4/24/2024
2024.0.12.11417 211 4/23/2024
2024.0.12.11400 199 4/22/2024
2024.0.12.11316 185 4/22/2024
2024.0.11.10220 192 4/11/2024
2024.0.11.10120 182 4/10/2024
2024.0.11.10119 176 4/10/2024
2024.0.11.10115 187 4/10/2024
2024.0.11.9914 236 4/8/2024
2024.0.11.9901 195 4/7/2024
2024.0.11.9823 207 4/7/2024
2024.0.11.9401 210 4/2/2024
2024.0.11.9301 220 4/1/2024
2024.0.11.9206 201 3/31/2024
2024.0.11.9205 200 3/31/2024
2024.0.11.8200 212 3/21/2024
2024.0.11.8122 189 3/21/2024
2024.0.11.8120 201 3/21/2024
2024.0.11.7320 282 3/13/2024
2024.0.11.7316 208 3/13/2024
2024.0.11.7310 200 3/13/2024
2024.0.11 202 3/13/2024
2024.0.10 227 3/3/2024
2024.0.9 209 2/27/2024
2024.0.8 252 2/1/2024
2024.0.7 208 1/26/2024
2024.0.6 191 1/25/2024
2024.0.5 184 1/24/2024
2024.0.4 192 1/24/2024
2024.0.3 186 1/22/2024
2024.0.2 254 1/10/2024
2024.0.1 206 1/9/2024
2024.0.1-alpha-3 172 1/9/2024
2024.0.1-alpha-2 145 1/9/2024
2024.0.1-alpha-1 178 1/3/2024
2024.0.0 250 12/26/2023
2023.0.27 209 12/21/2023
2023.0.26 197 12/21/2023
2023.0.25 229 12/11/2023
2023.0.24 221 12/8/2023
2023.0.23 189 12/6/2023
2023.0.21 200 12/4/2023
2023.0.20 215 11/27/2023
2023.0.19 196 11/20/2023
2023.0.18 220 10/25/2023
2023.0.17 284 10/22/2023
2023.0.16 236 10/16/2023
2023.0.16-alpha-1 196 10/16/2023
2023.0.15 240 10/14/2023
2023.0.14 207 10/14/2023
2023.0.13 213 10/14/2023
2023.0.12 225 10/14/2023
2023.0.11 222 10/10/2023
2023.0.10 211 10/9/2023
2023.0.9 280 8/16/2023
2023.0.8 272 8/15/2023
2023.0.8-alpha-2 363 5/31/2023
2023.0.7 262 5/12/2023
2023.0.6 483 5/10/2023
2023.0.5 289 5/7/2023
2023.0.4 310 4/22/2023
2023.0.3 334 4/19/2023
2023.0.2 314 4/6/2023
2023.0.1 391 3/13/2023