MaksIT.Persistence 2.0.0

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

MaksIT.Persistence

Line Coverage Branch Coverage Method Coverage

NuGet facade over linq2db + PostgreSQL for ASP.NET Core Engines: connection factory, FluentMigrator startup, and MaksIT.Results guards.

Table of Contents

Overview

MaksIT.Persistence wraps linq2db PostgreSQL wiring so Engine code depends on ILinq2DbConnectionFactory instead of copying DataOptions / ProviderName.PostgreSQL / startup wait in every product. Domain tables, Dto, FluentMapping content, and FluentMigrator migration classes stay in the product Engine.

Linq2Db queries stay in the product: persist/query services still call GetTable<T>(). This library hides connection lifetime, Postgres transients, and FluentMigrator bootstrap.

Need Register Inject
Scoped DataConnection RegisterLinq2Db(connectionString, mappingSchema?) ILinq2DbConnectionFactory
FluentMigrator wait / create-DB / retry MigrateUp RegisterPostgresMigrations(connectionString, assembly, options?) IRunMigrationsService

Work leases are not in this package: use MaksIT.Dapr (RegisterWorkLeases) for most first-party apps, or MaksIT.HAMode for maksit-nats only.

Result conventions

  • Success / failure: check result.IsSuccess. Map to HTTP with result.ToActionResult().
  • Cancellation: Linq2DbGuard rethrows OperationCanceledException (do not wrap as a failed Result).
  • Unique violation (23505): Linq2DbGuard maps to Conflict.
  • Missing row: product persist/query ports return NotFound — not this library.

Getting Started

Ensure that you have the following installed:

Installation

dotnet add package MaksIT.Persistence

Or in your .csproj:

<PackageReference Include="MaksIT.Persistence" Version="2.0.0" />

Registering services

Call from the product Engine Add*Engine, not from host JSON binding. Pass the Engine connection string; optional MappingSchema for fluent maps (omit to use attribute mapping).

using MaksIT.Persistence.Extensions;

services.RegisterLinq2Db(config.ConnectionString, ProductLinq2DbMapping.Schema);
services.RegisterPostgresMigrations(
  config.ConnectionString,
  typeof(BaselineSchema).Assembly,
  new PostgresMigrationOptions {
    EnsureCoordinationTables = ct => CoordinationTableProvisioner.EnsureAsync(config.ConnectionString, ct),
    VerifySchema = ct => VerifyCoreSchemaAsync(config.ConnectionString, ct),
  });

Schema changes go in a new FluentMigrator [Migration] (Create.Table / Alter.Table.AddColumn; Drop/rename needs a separate decision). Host Program.cs before RunAsync:

await app.Services.EnsureLinq2DbMigratedAsync();

Product persist/query:

using var db = connectionFactory.Create();
var row = db.GetTable<UserDto>().FirstOrDefault(u => u.Id == id);

What stays in the product

  • Table names, Dto, FluentMapping entity list, FluentMigrator [Migration] classes
  • Coordination DDL unique to the product (hook on PostgresMigrationOptions)
  • I*PersistenceService / I*QueryService and domain services
  • HA work leases (Dapr or HAMode)

Contributing

See CONTRIBUTING.md.

Contact

For questions or support, contact:

License

This project is licensed under the MIT License. See the LICENSE.md file for details.

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

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
2.0.0 171 8/21/2026
1.0.0 202 8/17/2026