DKNet.AspCore.Idempotency.Relational
10.1.17
See the version list below for details.
dotnet add package DKNet.AspCore.Idempotency.Relational --version 10.1.17
NuGet\Install-Package DKNet.AspCore.Idempotency.Relational -Version 10.1.17
<PackageReference Include="DKNet.AspCore.Idempotency.Relational" Version="10.1.17" />
<PackageVersion Include="DKNet.AspCore.Idempotency.Relational" Version="10.1.17" />
<PackageReference Include="DKNet.AspCore.Idempotency.Relational" />
paket add DKNet.AspCore.Idempotency.Relational --version 10.1.17
#r "nuget: DKNet.AspCore.Idempotency.Relational, 10.1.17"
#:package DKNet.AspCore.Idempotency.Relational@10.1.17
#addin nuget:?package=DKNet.AspCore.Idempotency.Relational&version=10.1.17
#tool nuget:?package=DKNet.AspCore.Idempotency.Relational&version=10.1.17
DKNet.AspCore.Idempotency.Relational
Shared Entity Framework Core base for building relational DKNet.AspCore.Idempotency stores — the entity, the
entity mapping, the shared DbContext, and the concurrency-safe insert-or-query pattern that
DKNet.AspCore.Idempotency.MsSqlStore and DKNet.AspCore.Idempotency.NpgsqlStore both derive from.
This is an internal base package, not something app authors register directly. If you are adding idempotency to an app, install
DKNet.AspCore.Idempotencyplus a concrete provider package (.MsSqlStore/.NpgsqlStore) instead. Use this package only when implementing support for a new relational database.
Features
- Shared
IdempotencyKeyEntityandIEntityTypeConfiguration<IdempotencyKeyEntity>mapping every relational provider reuses as-is - Shared
IdempotencyDbContextbase with automatic discovery of the derived provider's own entity configuration - Race-safe insert-or-query reservation pattern (
IdempotencyRelationalStore<TContext>) backed by a unique-index guarantee, including atomic reclaim of expired reservations - Per-connection-string migration guard so a process serving multiple databases migrates each one exactly once
- Only two seams left to each provider: the response-body column type/check-constraint SQL, and how to recognize that provider's own unique-key-violation error
Installation
dotnet add package DKNet.AspCore.Idempotency.Relational
Quick Start — implementing a new provider store
A new relational provider derives four types from this package:
// 1. Closed DbContext
internal sealed class IdempotencyDbContext(DbContextOptions<IdempotencyDbContext> options)
: DKNet.AspCore.Idempotency.Relational.Data.IdempotencyDbContext(options);
// 2. Provider-specific mapping details
internal sealed class IdempotencyKeyConfiguration
: DKNet.AspCore.Idempotency.Relational.Data.Configurations.IdempotencyKeyConfiguration
{
protected override string BodyColumnType => "text";
protected override string StatusCodeCheckConstraintSql => "\"StatusCode\" BETWEEN 100 AND 599";
}
// 3. Provider-specific unique-violation detection
internal sealed class IdempotencyPostgresStore(
IServiceProvider serviceProvider, IOptions<IdempotencyOptions> options, ILogger<IdempotencyPostgresStore> logger)
: IdempotencyRelationalStore<IdempotencyDbContext>(serviceProvider, options, logger)
{
protected override bool IsProviderUniqueViolation(DbUpdateException ex) =>
ex.InnerException is PostgresException { SqlState: PostgresErrorCodes.UniqueViolation };
}
// 4. DI wiring (own project's setup extension)
services.AddDbContext<IdempotencyDbContext>(o => o.UseNpgsql(connectionString))
.AddDbContextFactory<IdempotencyDbContext>();
services.AddIdempotentKey<IdempotencyPostgresStore>();
Because the base types here are internal, the new provider project must be added to this package's
InternalsVisibleTo list.
Customisation reference
This package exposes no public API, so there is nothing to configure and nothing to register. The four types it
declares — IdempotencyRelationalStore<TContext>, IdempotencyDbContext, IdempotencyKeyEntity and
IdempotencyKeyConfiguration — are all internal, and its InternalsVisibleTo list names only
DKNet.AspCore.Idempotency.MsSqlStore, DKNet.AspCore.Idempotency.NpgsqlStore and their two test projects. Adding
this package to an application changes nothing about that application.
The runtime knobs that affect a relational store are the core package's IdempotencyOptions — see
DKNet.AspCore.Idempotency.
Of those, this base reads only InFlightReservationTimeout (30 seconds by default), the lifetime of the StatusCode = 102 reservation row on both the fresh-insert and the reclaim path.
For in-repo provider authors, the internal contract is two protected abstract members and one override:
| Seam | Declared on | Example values |
|---|---|---|
BodyColumnType |
IdempotencyKeyConfiguration |
nvarchar(max) on SQL Server, text on PostgreSQL |
StatusCodeCheckConstraintSql |
IdempotencyKeyConfiguration |
[StatusCode] BETWEEN 100 AND 599 vs "StatusCode" BETWEEN 100 AND 599 |
IsProviderUniqueViolation(DbUpdateException) |
IdempotencyRelationalStore<TContext> |
SqlException { Number: 2601 or 2627 } vs PostgresException { SqlState: 23505 } — never a message substring, which the server localises |
Everything else — the table name, column lengths, the UX_CompositeKey unique index, the IX_IdempotencyKeys_ExpiresAt
index and the reserve/complete/reclaim flow — is fixed by the shared mapping and cannot be overridden.
Requirements
- .NET 10.0+
Microsoft.EntityFrameworkCore/Microsoft.EntityFrameworkCore.Relational- DKNet.AspCore.Idempotency (automatically included)
Full documentation
See DKNet.AspCore.Idempotency.Relational for the full feature breakdown, mapping defaults, and gotchas.
License
MIT — see LICENSE.
About
Developed by Steven Hoang.
| 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
- DKNet.AspCore.Idempotency (>= 10.1.17)
- Microsoft.EntityFrameworkCore (>= 10.0.11)
- Microsoft.EntityFrameworkCore.Relational (>= 10.0.11)
- Microsoft.Extensions.Hosting.Abstractions (>= 10.0.11)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on DKNet.AspCore.Idempotency.Relational:
| Package | Downloads |
|---|---|
|
DKNet.AspCore.Idempotency.MsSqlStore
DKNet is an enterprise-grade .NET library collection focused on advanced EF Core extensions, dynamic predicate building, and the Specification pattern. It provides production-ready tools for building robust, type-safe, and testable data access layers, including dynamic LINQ support, LinqKit integration. Designed for modern cloud-native applications, DKNet enforces strict code quality, async best practices, and full documentation for all public APIs. Enterprise-grade .NET library suite for modern application development, featuring advanced EF Core extensions (dynamic predicates, specifications, LinqKit), robust Domain-Driven Design (DDD) patterns, and domain event support. DKNet empowers scalable, maintainable, and testable solutions with type-safe validation, async/await, XML documentation, and high code quality standards. Ideal for cloud-native, microservices, and enterprise architectures. |
|
|
DKNet.AspCore.Idempotency.NpgsqlStore
DKNet is an enterprise-grade .NET library collection focused on advanced EF Core extensions, dynamic predicate building, and the Specification pattern. It provides production-ready tools for building robust, type-safe, and testable data access layers, including dynamic LINQ support, LinqKit integration. Designed for modern cloud-native applications, DKNet enforces strict code quality, async best practices, and full documentation for all public APIs. Enterprise-grade .NET library suite for modern application development, featuring advanced EF Core extensions (dynamic predicates, specifications, LinqKit), robust Domain-Driven Design (DDD) patterns, and domain event support. DKNet empowers scalable, maintainable, and testable solutions with type-safe validation, async/await, XML documentation, and high code quality standards. Ideal for cloud-native, microservices, and enterprise architectures. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 10.1.19 | 38 | 9/3/2026 |
| 10.1.18 | 41 | 9/3/2026 |
| 10.1.17 | 46 | 9/3/2026 |
| 10.1.16 | 41 | 9/3/2026 |
| 10.1.15 | 77 | 9/1/2026 |
| 10.1.14 | 78 | 9/1/2026 |
| 10.1.13 | 96 | 8/31/2026 |
| 10.1.12 | 111 | 8/25/2026 |
| 10.1.11 | 112 | 8/24/2026 |
| 10.1.10 | 122 | 8/22/2026 |
| 10.1.9 | 118 | 8/22/2026 |
| 10.1.8 | 104 | 8/21/2026 |
| 10.1.7 | 121 | 8/21/2026 |
| 10.1.6 | 119 | 8/21/2026 |