Raycynix.Extensions.Database
2.0.0
dotnet add package Raycynix.Extensions.Database --version 2.0.0
NuGet\Install-Package Raycynix.Extensions.Database -Version 2.0.0
<PackageReference Include="Raycynix.Extensions.Database" Version="2.0.0" />
<PackageVersion Include="Raycynix.Extensions.Database" Version="2.0.0" />
<PackageReference Include="Raycynix.Extensions.Database" />
paket add Raycynix.Extensions.Database --version 2.0.0
#r "nuget: Raycynix.Extensions.Database, 2.0.0"
#:package Raycynix.Extensions.Database@2.0.0
#addin nuget:?package=Raycynix.Extensions.Database&version=2.0.0
#tool nuget:?package=Raycynix.Extensions.Database&version=2.0.0
Raycynix.Extensions.Database
Core EF Core database infrastructure for Raycynix applications.
What It Provides
AddRaycynixDatabase(...)zero-setup registration with the defaultDatabaseContextAddRaycynixDatabase<TContext>(...)for custom Raycynix database contexts- marker and explicit assembly overloads for model configurators and EF Core migrations
- model assembly discovery through
AddAssembly(...) RaycynixDatabaseContext,DatabaseContext,GenericConfigurator<T>, and table-name helpers- provider selection through provider packages such as PostgreSQL, SQL Server, MySQL, or SQLite
- startup initialization through
IDatabaseInitializer - default no-op database observability
Shared contracts and configuration models live in Raycynix.Extensions.Database.Abstractions.
Basic Usage
For simple applications, call AddRaycynixDatabase(...) and one provider. The application entry assembly is registered automatically for configurator discovery and migrations.
builder.Services
.AddRaycynixDatabase(builder.Configuration, options =>
{
options.UseMigrations = true;
options.EnsureCreated = false;
})
.AddPostgreSql();
Exactly one provider must be registered:
AddPostgreSql()AddMsSql()AddMySql()AddSqlite()
Configuration
{
"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
}
}
Provider-specific settings are nested under DatabaseConfiguration:
{
"DatabaseConfiguration": {
"PostgreSqlConfiguration": {
"Pooling": true,
"MinimumPoolSize": 5,
"MaximumPoolSize": 50,
"CommandTimeoutSeconds": 30,
"IncludeErrorDetail": false
}
}
}
Provider packages validate their own structured connection requirements before building connection strings.
Custom Contexts
public sealed class AppDatabaseContext : RaycynixDatabaseContext
{
public AppDatabaseContext(
DbContextOptions<AppDatabaseContext> options,
DatabaseConfiguration config,
IDatabaseModelAssemblyRegistry modelAssemblyRegistry,
IDatabaseObservability observability,
ILogger<RaycynixDatabaseContext> logger,
IServiceProvider serviceProvider)
: base(options, config, modelAssemblyRegistry, observability, logger, serviceProvider)
{
}
}
builder.Services
.AddRaycynixDatabase<AppDatabaseContext>(builder.Configuration)
.AddPostgreSql();
Assembly Registration
The default registration scans the application entry assembly. For modular applications, register model assemblies explicitly:
builder.Services
.AddRaycynixDatabase(builder.Configuration, registerCallerAssembly: false)
.AddAssembly<IdentityDatabaseMarker>()
.AddAssembly<AuditDatabaseMarker>()
.AddPostgreSql();
When model configurators and migrations live in different assemblies, use marker overloads:
builder.Services
.AddRaycynixDatabase<DatabaseContext, AppModelMarker, AppMigrationsMarker>(builder.Configuration)
.AddPostgreSql();
or explicit assemblies:
builder.Services
.AddRaycynixDatabase<DatabaseContext>(
builder.Configuration,
migrationsAssembly: typeof(AppMigrationsMarker).Assembly,
modelAssembly: typeof(AppModelMarker).Assembly)
.AddPostgreSql();
If AddRaycynixDatabase is called more than once with the same context, only the first call may configure DatabaseConfiguration. Later calls can add assemblies but cannot pass another setup callback.
Configurators
Configurators contribute EF Core model configuration to the shared context:
[DatabaseTable("orders")]
public sealed class OrderConfigurator : GenericConfigurator<Order>
{
public override Type[] DependsOn => [];
public override void Configure(ModelBuilder modelBuilder)
{
var entity = ConfigureEntity(modelBuilder);
entity.HasKey(static order => order.Id);
}
}
Table names are resolved in this order:
- explicit runtime name passed to
ConfigureEntity(modelBuilder, tableName) DatabaseTableAttributeon the configurator- entity type name
If runtime values change the model shape, override GetModelShapeCacheKey():
protected override string? GetModelShapeCacheKey()
{
return options.TableName;
}
Startup Initialization
Use these packages to run initialization during startup:
Raycynix.Extensions.Database.HostingRaycynix.Extensions.Database.AspNetCore
Observability
Database tracing and metrics live in Raycynix.Extensions.Database.Observability:
builder.Services
.AddRaycynixDatabase(builder.Configuration)
.AddPostgreSql()
.AddObservability();
| Product | Versions 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. |
-
net10.0
- Microsoft.Extensions.DependencyInjection (>= 10.0.7)
- Raycynix.Extensions.Configuration (>= 2.0.0)
- Raycynix.Extensions.Database.Abstractions (>= 2.0.0)
- Raycynix.Extensions.Logging (>= 2.1.0)
NuGet packages (1)
Showing the top 1 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. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Added explicit model and migrations assembly registration, provider-specific validation hooks, safer DbContext registration, improved configurator dependency diagnostics, and default no-op database observability.