Raycynix.Extensions.Database 1.0.0

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

Raycynix.Extensions.Database

Raycynix.Extensions.Database is the core database package.

What it contains

  • AddRaycynixDatabase(...)
  • AddRaycynixDatabaseAssembly(...)
  • DatabaseBuilder.AddAssembly(...)
  • DatabaseContext
  • DatabaseConfiguration
  • provider registration infrastructure
  • IDatabaseInitializer
  • DatabaseInitializer

What it does not contain

  • PostgreSQL provider integration
  • SQL Server provider integration
  • MySQL provider integration
  • SQLite provider integration
  • WebApplication extensions
  • ASP.NET Core startup integration
  • generic-host startup integration

Usage

builder.Services.AddRaycynixDatabase(builder.Configuration, options =>
{
    options.UseMigrations = true;
});

appsettings.json

Core settings stay under DatabaseConfiguration:

{
  "DatabaseConfiguration": {
    "ConnectionString": "Host=localhost;Port=5432;Database=app;Username=app;Password=secret",
    "UseMigrations": true,
    "EnsureCreated": false,
    "EnableSeed": true,
    "EnableLazyLoading": false,
    "EnableAutoDetectChanges": true,
    "UseQueryTrackingByDefault": true,
    "RetryCount": 5,
    "RetryDelaySeconds": 10
  }
}

Then add exactly one provider package and extend the registration:

builder.Services
    .AddRaycynixDatabase(builder.Configuration, options =>
    {
        options.UseMigrations = true;
    })
    .AddPostgreSql();

Equivalent provider packages expose:

  • AddPostgreSql()
  • AddMsSql()
  • AddMySql()
  • AddSqlite()

The provider package is selected by registration, not by a legacy Provider configuration key.

Provider-specific settings remain nested under the same root section:

{
  "DatabaseConfiguration": {
    "PostgreSqlConfiguration": {
      "Pooling": true,
      "MinimumPoolSize": 5,
      "MaximumPoolSize": 50,
      "CommandTimeoutSeconds": 30,
      "IncludeErrorDetail": false
    }
  }
}

If a reusable package contributes EF Core configurators to the shared DatabaseContext, register its assembly explicitly:

builder.Services.AddRaycynixDatabase(builder.Configuration)
    .AddAssembly<SomePackageMarker>();

This keeps a single shared DatabaseContext while allowing infrastructure packages to extend the model without creating their own context.

By default, AddRaycynixDatabase(...) also registers the caller assembly for configurator discovery. This is convenient when the application's own configurators live next to the startup code.

If configurator assemblies should be controlled explicitly, disable caller-assembly registration and add the required assemblies yourself:

builder.Services
    .AddRaycynixDatabase(builder.Configuration, registerCallerAssembly: false)
    .AddPostgreSql()
    .AddAssembly<IdentityModelMarker>()
    .AddAssembly<AuditModelMarker>();

Use explicit assembly registration in tests, plugin-style architectures, or shared assemblies that contain configurators with optional dependencies.

Provider-specific packages extend the same fluent builder, and the core package expects exactly one database provider registration.

Table names can be configured in three ways, in this order:

  1. an explicit runtime name passed to ConfigureEntity(modelBuilder, tableName)
  2. DatabaseTableAttribute on the configurator
  3. the entity type name

For static table names, configurators can declare the default mapping with DatabaseTableAttribute instead of calling ToTable(...) manually inside Configure(...).

For runtime overrides, prefer injecting configuration into the configurator and passing the resolved name to ConfigureEntity(modelBuilder, tableName).

When a configurator changes the model shape at runtime, override GetModelShapeCacheKey() so EF Core does not reuse an incompatible cached model.

public sealed class OrdersDatabaseOptions
{
    public string TableName { get; init; } = "orders";
}

public sealed class OrderConfigurator(
    OrdersDatabaseOptions options) : GenericConfigurator<Order>
{
    public override Type[] DependsOn => [];

    public override void Configure(ModelBuilder modelBuilder)
    {
        var entity = ConfigureEntity(modelBuilder, options.TableName);
        entity.HasKey(static current => current.Id);
    }

    protected override string? GetModelShapeCacheKey()
    {
        return options.TableName;
    }
}

If you want an explicit fluent call, use modelBuilder.Entity<T>().EntityName(tableName).

If a configurator relies on runtime-dependent mappings such as table names, schemas, or provider-conditioned model shape, keep those values stable within a given service provider and include them in GetModelShapeCacheKey().

If you want to run initialization during startup, use one of these packages:

  • Raycynix.Extensions.Database.Hosting
  • Raycynix.Extensions.Database.AspNetCore
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 (6)

Showing the top 5 NuGet packages that depend on Raycynix.Extensions.Database:

Package Downloads
Raycynix.Extensions.Messaging.Database

Database-backed messaging inbox and outbox persistence with ambient unit-of-work support, optimistic concurrency leasing, retention cleanup, and configuration-based setup on the shared Raycynix DatabaseContext.

Raycynix.Extensions.Database.Hosting

Generic host startup integration for Raycynix database initialization through IDatabaseInitializer.

Raycynix.Extensions.Database.MySql

MySQL provider integration for Raycynix.Extensions.Database with AddMySql registration, MySQL connection-string composition, and EF Core UseMySQL configuration.

Raycynix.Extensions.Database.PostgreSql

PostgreSQL provider integration for Raycynix.Extensions.Database with AddPostgreSql registration, Npgsql connection-string composition, and EF Core UseNpgsql configuration.

Raycynix.Extensions.Database.MsSql

SQL Server provider integration for Raycynix.Extensions.Database with AddMsSql registration, SQL Server connection-string composition, and EF Core UseSqlServer configuration.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0 35 4/8/2026
0.4.0 37 4/8/2026

See the repository changelog and release history for package-specific changes and breaking updates.