/dknet-skills:dknet-idempotencyfrom dknet-skills
Covers DKNet.AspCore.Idempotency endpoint filter for ASP.NET Core minimal APIs, making POST/PUT/DELETE endpoints retry-safe via Idempotency-Key header with SQL Server, PostgreSQL, or Redis stores.
Ships in dknet-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
This skill teaches the DKNet.AspCore.Idempotency endpoint filter for ASP.NET Core minimal APIs and its four store packages. Read references/DKNet.AspCore.Idempotency.md first — it owns every cross-cutting concept (options, scope resolution, conflict handling); each store's own reference file covers only what differs for that database. references/diagnostics.md is a single lookup table for every exception/status code this feature can produce.
| Package | Install | What it gives you | Depends on | Reference |
|---|---|---|---|---|
DKNet.AspCore.Idempotency | dotnet add package DKNet.AspCore.Idempotency | RequiredIdempotentKey() endpoint filter, AddIdempotentKey()/AddIdempotentKey<TStore>(), IdempotencyOptions, IdempotentConflictHandling, the in-process dev-only store | DKNet.Fw.Extensions | references/DKNet.AspCore.Idempotency.md |
DKNet.AspCore.Idempotency.Relational | (never add directly — see Rules) | Shared EF Core reserve/check/complete algorithm behind MsSqlStore and NpgsqlStore | DKNet.AspCore.Idempotency, EF Core | references/DKNet.AspCore.Idempotency.Relational.md |
DKNet.AspCore.Idempotency.MsSqlStore | dotnet add package DKNet.AspCore.Idempotency.MsSqlStore | AddIdempotencyWithMsSqlStore(connectionString, config?) — SQL Server-backed store, auto-migrated at startup | DKNet.AspCore.Idempotency, .Relational, EF Core SqlServer | references/DKNet.AspCore.Idempotency.MsSqlStore.md |
DKNet.AspCore.Idempotency.NpgsqlStore | dotnet add package DKNet.AspCore.Idempotency.NpgsqlStore | AddIdempotencyWithNpgsqlStore(connectionString, config?) — PostgreSQL-backed store, auto-migrated at startup | DKNet.AspCore.Idempotency, .Relational, Npgsql EF Core | references/DKNet.AspCore.Idempotency.NpgsqlStore.md |
DKNet.AspCore.Idempotency.RedisStore | dotnet add package DKNet.AspCore.Idempotency.RedisStore | AddIdempotencyWithRedisStore(connectionString, config?) — Redis-backed store, SET NX + native TTLs, no schema | DKNet.AspCore.Idempotency, StackExchange.Redis | references/DKNet.AspCore.Idempotency.RedisStore.md |
using DKNet.AspCore.Idempotency;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddIdempotentKey();
var app = builder.Build();
app.MapPost("/orders", () => TypedResults.Created("/orders/1"))
.RequiredIdempotentKey();
await app.RunAsync();
This is the whole wiring: register a store (AddIdempotentKey() here selects the process-local, dev-only default), then opt an endpoint in with RequiredIdempotentKey(). A client resends the same X-Idempotency-Key header on a retry and gets 409 instead of a second order. Swap AddIdempotentKey() for AddIdempotencyWithMsSqlStore(...)/AddIdempotencyWithNpgsqlStore(...)/AddIdempotencyWithRedisStore(...) for production — see How to below.
AddIdempotentKey() or a store's AddIdempotencyWithXxxStore(...)) before app.Build() and before mapping any RequiredIdempotentKey() endpoint — the filter resolves IIdempotencyKeyStore/IOptions<IdempotencyOptions> from DI at request time, but registration order still decides which store, and which call's config, wins.AddIdempotentKey() with no type argument) outside local dev/tests. It is a ConcurrentDictionary, process-local, lost on restart, and logs a startup warning while active. Use a MsSqlStore/NpgsqlStore/RedisStore package in production.RequiredIdempotentKey() extends RouteHandlerBuilder/RouteGroupBuilder only — minimal APIs, not MVC controllers. There is no [Idempotent] attribute anywhere in this package family.RequiredIdempotentKey() with no verb argument covers POST only; name every other verb explicitly (RequiredIdempotentKey("POST", "DELETE")). An endpoint mapped with app.Map(...) and no routed verb is never covered, in a group or alone, and there is no warning when a mutating verb falls outside the covered set.With overload — AddIdempotencyWithMsSqlStore/AddIdempotencyWithNpgsqlStore/AddIdempotencyWithRedisStore — to get a working store. The plain AddIdempotencyMsSqlStore/AddIdempotencyNpgsqlStore/AddIdempotencyRedisStore overload registers only infrastructure (DbContext/migration service, or the Redis connection); it never registers IIdempotencyKeyStore itself.IServiceCollection: a second call to the same or a different store's Add..., even with a different connection string, is a silent no-op — no exception, no log. Register idempotency exactly once per container.new IdempotencyInMemoryStore(), new IdempotencySqlServerStore(...), new IdempotencyPostgresStore(...), new IdempotencyRedisStore(...)) or pass one to AddIdempotentKey<T>() from application code — every shipped store is internal. Select a store only through its package's Add... extension.DKNet.AspCore.Idempotency.Relational to an application directly. It has no public API and no Add... method — it exists only so MsSqlStore/NpgsqlStore can share the reserve/check/complete algorithm.IdempotentConflictHandling.ConflictResponse → 409. Set ConflictHandling = IdempotentConflictHandling.CachedResult to replay the original cached status/body/content-type instead of a bare conflict.IdempotentKey or IdempotentKeyInfo.SafeKey as a lookup value — only the hashed CompositeKey is ever stored, and SafeKey exists solely for safe display/logging.IsKeyProcessedAsync is never wrapped in try/catch by the filter — a store outage on the duplicate check surfaces as an unhandled 500, asymmetric with MarkKeyAsProcessedAsync failures (caught, logged, response still returned). Harden the store, not the filter.IdempotencyKeys table grows unbounded unless you add your own cleanup job against the indexed ExpiresAt column.IIdempotencyKeyStore.IsKeyProcessedAsync must be a single atomic reserve (unique index insert, SET NX, or CAS) keyed on IdempotentKeyInfo.CompositeKey — never a Get-then-Set, and never keyed on SafeKey.When: several endpoints under one prefix need the same protection, and some of them use verbs beyond the POST-only default.
using DKNet.AspCore.Idempotency;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddIdempotentKey();
var app = builder.Build();
var orders = app.MapGroup("/api/orders").RequiredIdempotentKey(); // POST only (default)
var admin = app.MapGroup("/api/admin").RequiredIdempotentKey("POST", "DELETE"); // explicit verbs
orders.MapPost("/", () => TypedResults.Created("/api/orders/1")); // covered
orders.MapGet("/{id}", (string id) => TypedResults.Ok(id)); // untouched: GET
admin.MapDelete("/tenants/{id}", (string id) => TypedResults.Ok(id)); // covered: named
await app.RunAsync();
Notes: coverage is decided once, at app start, from each endpoint's routed verb — an X-HTTP-Method-Override header can't move an endpoint into or out of coverage. app.Map(...) with no verb constraint is never covered.
When: a duplicate request should transparently get the exact original response back instead of an explicit conflict.
using DKNet.AspCore.Idempotency;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddIdempotentKey(options =>
{
options.ConflictHandling = IdempotentConflictHandling.CachedResult;
options.Expiration = TimeSpan.FromHours(24);
});
Notes: the replayed status/body/content-type come from the store's CachedResponse, not from re-running the handler. If nothing is cached yet (still in-flight), the caller still gets 409 even under CachedResult.
When: two different callers must not collide on the same key against the same endpoint.
using DKNet.AspCore.Idempotency;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddIdempotentKey(options =>
{
options.ScopeHmacSecret = builder.Configuration["Idempotency:HmacSecret"];
options.IncludeClientIpInScope = true; // last-resort fallback
});
Notes: the default chain is user claim → HMAC'd Authorization header (only if ScopeHmacSecret is set) → client IP (only if IncludeClientIpInScope) → empty scope. Setting options.KeyScopeResolver to your own Func<HttpContext, string?> instead skips this whole chain, even if the other two are also set — see the core reference for that recipe.
When: the app has a SQL Server instance and wants a queryable, durable idempotency ledger.
using DKNet.AspCore.Idempotency;
using DKNet.AspCore.Idempotency.MsSqlStore;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddIdempotencyWithMsSqlStore(builder.Configuration.GetConnectionString("IdempotencyDb")!);
var app = builder.Build();
app.MapPost("/orders", () => Results.Ok()).RequiredIdempotentKey();
await app.RunAsync();
Notes: the IdempotencyKeys schema is created automatically the first time app.RunAsync()/Run() actually starts hosted services. dotnet ef tooling against this context reads IDEMPOTENCY_MSSQL_CONNECTION from the environment, never from configuration.
When: same need as SQL Server, on Postgres — and the store's tests need to run natively on ARM64.
using DKNet.AspCore.Idempotency;
using DKNet.AspCore.Idempotency.NpgsqlStore;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddIdempotencyWithNpgsqlStore(builder.Configuration.GetConnectionString("IdempotencyDb")!);
var app = builder.Build();
app.MapPost("/orders", () => Results.Ok()).RequiredIdempotentKey();
await app.RunAsync();
Notes: same shape as SQL Server — migrations apply automatically at startup. Unlike SQL Server's x64-only container image, Postgres containers run natively on ARM64.
When: the lowest latency and no owned schema/migrations matter more than a queryable audit table.
using DKNet.AspCore.Idempotency;
using DKNet.AspCore.Idempotency.RedisStore;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddIdempotencyWithRedisStore(builder.Configuration.GetConnectionString("Redis")!);
var app = builder.Build();
app.MapPost("/orders", () => Results.Ok()).RequiredIdempotentKey();
await app.RunAsync();
Notes: no schema, no migration — both the in-flight reservation and the completed response are native Redis TTLs (SET NX for the reserve, plain SET for the complete). AddIdempotencyWithRedisStore also registers IDistributedCache, unused by this store but harmless.
IConnectionMultiplexer with the Redis storeWhen: the app already owns a Redis connection for other purposes and must not open a second one.
using DKNet.AspCore.Idempotency.RedisStore;
using StackExchange.Redis;
var builder = WebApplication.CreateBuilder(args);
IConnectionMultiplexer existingMultiplexer = ConnectionMultiplexer.Connect("localhost:6379");
builder.Services.AddIdempotencyRedisStore(existingMultiplexer);
builder.Services.AddIdempotencyWithRedisStore(builder.Configuration.GetConnectionString("Redis")!);
var app = builder.Build();
await app.RunAsync();
Notes: AddIdempotencyRedisStore(multiplexer) must run first — the connection-string overload inside AddIdempotencyWithRedisStore then sees IConnectionMultiplexer already registered and skips connecting a second one. It still registers IDistributedCache regardless; there is no flag to suppress that.
IIdempotencyKeyStoreWhen: none of the shipped stores fit (e.g. DynamoDB, a message broker's own dedup table).
using DKNet.AspCore.Idempotency.Filtering;
using DKNet.AspCore.Idempotency.Store;
public sealed class MyIdempotencyKeyStore : IIdempotencyKeyStore
{
public ValueTask<(bool processed, CachedResponse? response)> IsKeyProcessedAsync(IdempotentKeyInfo keyInfo)
{
// Atomic check-and-reserve: absent -> write a reservation, return (false, null).
throw new NotImplementedException();
}
public ValueTask MarkKeyAsProcessedAsync(IdempotentKeyInfo keyInfo, CachedResponse cachedResponse)
{
// Overwrite this caller's reservation with cachedResponse.
throw new NotImplementedException();
}
}
That store type lives in its own file, like any other application class. Wire it up from Program.cs:
using DKNet.AspCore.Idempotency;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddIdempotentKey<MyIdempotencyKeyStore>();
Notes: IsKeyProcessedAsync must be atomic (unique index / SET NX / CAS — never Get-then-Set), must use a distinguishable in-flight sentinel (every shipped store uses HTTP 102), must expire that reservation after InFlightReservationTimeout, and must hash IdempotentKeyInfo.CompositeKey (never SafeKey).
Per protected request, in order:
IdempotencyHeaderKey (default X-Idempotency-Key), builds an IdempotentKeyInfo (endpoint and method upper-invariant, scope from KeyScopeResolver or the default chain).IdempotentKeyInfo.IsValid(options) checks presence, then length, then format (under a fixed 100ms match timeout). Any failure short-circuits with 400 — the handler never runs.store.IsKeyProcessedAsync(keyInfo). Every store hashes CompositeKey ($"{Scope}:{Method}:{Endpoint}:{IdempotentKey}", SHA-256) before using it as the actual lookup key:
102 and returns (false, null) — the handler runs.(true, null) — the filter answers 409 (or, under CachedResult, the same 409, since nothing is cached yet).(true, cachedResponse) — the filter answers 409 (ConflictResponse) or replays cachedResponse verbatim (CachedResult).InFlightReservationTimeout elapsed) → the store reclaims it for exactly one racing caller; every other racer re-reads and branches as above.store.MarkKeyAsProcessedAsync — only if the response's status code is cacheable (Min/MaxStatusCodeForCaching or AdditionalCacheableStatusCodes). A serialization/store failure here is caught, logged, and never fails the original response.Expiration as the completed entry's absolute lifetime — a relational store via the ExpiresAt column (reclaimed opportunistically), Redis via native TTL.AddIdempotentKey()/AddIdempotentKey<T>() call registers the store either way, but a named store call always replaces an already-registered in-process default (and its config then decides shared options) — while a second named store call after the first is a complete no-op, config included. Reordering two AddIdempotentKey<T>(...) calls silently changes which options apply.PUT in a POST-only-default group is simply unprotected, with nothing flagging it anywhere. Audit the group's mutating routes against the verb list you actually passed.102 status is a deliberate in-flight sentinel, not a bug. Every store uses HTTP 102 to mark a reservation — legal under the relational stores' 100..599 check constraint but never a real completed response. Always branch on the status value, not just row/key existence.SafeKey must never back storage or lookup. It strips control characters for safe logging/display; only CompositeKey (the raw key, hashed) is ever stored or compared. Substituting SafeKey into custom store code would silently collapse distinct keys that differ only in stripped control characters.IdempotencyKeyPattern (nested quantifiers) still burns CPU on a long key before it safely times out into a 400. Write custom patterns to be linear; don't rely on the timeout for performance.IsKeyProcessedAsync failures are not caught; MarkKeyAsProcessedAsync failures are. A store outage on the duplicate check bubbles up as an unhandled 500; a caching failure after the handler ran is swallowed (logged) and the real response still reaches the client. The two behave completely differently for the same underlying outage, depending only on when it happens.ExpiresAt is indexed on both MsSqlStore and NpgsqlStore so you can query it, but nothing sweeps it — expired rows are reclaimed only opportunistically, on the next collision for that exact key.nvarchar(max)/text column (max 1,048,576 chars); Redis stores it as the value string. PII or secrets in a cached 2xx body persist for the full Expiration window.IConfiguration. dotnet ef design-time factories read IDEMPOTENCY_MSSQL_CONNECTION / IDEMPOTENCY_NPGSQL_CONNECTION from the process environment — running EF tooling without exporting that specific variable throws InvalidOperationException even when the app's own connection string is fine.AddIdempotencyRedisStore(connectionString) always registers IDistributedCache, even though IdempotencyRedisStore never uses it. An unused Redis-backed distributed cache shows up in the container with no way to suppress it from this package — harmless, but unrequested.IdempotencyDbContext types exist — one in the Relational base, one closed per provider package. Only matters if you're extending this family (both are internal), but explains a confusing type-resolution error if you ever read two provider packages' source side by side.services.AddIdempotency(...) / services.AddDKNetIdempotency(...) — do not exist. The real call is AddIdempotentKey() / AddIdempotentKey<TStore>().[Idempotent] attribute on a controller action — does not exist; this family only extends RouteHandlerBuilder/RouteGroupBuilder for minimal APIs.new IdempotencyInMemoryStore(), new IdempotencySqlServerStore(...), new IdempotencyPostgresStore(...), new IdempotencyRedisStore(...) — every shipped store is internal; select one through Add... extensions only.IdempotencyMsSqlOptions / IdempotencyNpgsqlOptions / RedisIdempotencyOptions / IdempotencyRelationalOptions — none of these types exist. Every store shares one options type: DKNet.AspCore.Idempotency.IdempotencyOptions.AddDbContext<DKNet.AspCore.Idempotency.Relational.Data.IdempotencyDbContext>(...) from application code — impossible; that base type is abstract and internal.app.Services.GetRequiredService<IdempotencyRedisStore>() / <IdempotencySqlServerStore>() / <IdempotencyPostgresStore>() — none is resolvable by its concrete type; resolve IIdempotencyKeyStore instead.RequiredIdempotentKey() with no verb argument on a group covers PUT/DELETE too — the default is POST only.ConflictHandling defaults to replaying the cached response — the default is ConflictResponse (409), not CachedResult.MarkKeyAsProcessedAsync yourself to "pre-warm" a key — it's meant to be called exactly once by the filter, from the caller that won the reservation.options.FailOpen = false looks plausible enough that it is worth showing why it fails — it appears verbatim inside this repo's own shipped XML <example> doc comments for AddIdempotencyWithMsSqlStore/AddIdempotencyWithNpgsqlStore, but IdempotencyOptions has no such member:
// no-compile
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddIdempotencyWithMsSqlStore(
builder.Configuration.GetConnectionString("IdempotencyDb")!,
options =>
{
options.Expiration = TimeSpan.FromHours(48);
options.FailOpen = false; // IdempotencyOptions has no FailOpen member — CS1061
});
The plain (non-With) overload has no config parameter — that belongs only to the With overload:
// no-compile
var services = new ServiceCollection();
var connectionString = "Server=.;Database=IdempotencyDb;TrustServerCertificate=True;";
services.AddIdempotencyMsSqlStore(connectionString, options => options.Expiration = TimeSpan.FromHours(1));
// AddIdempotencyMsSqlStore(IServiceCollection, string) has no `config` parameter — CS1501.
// Use AddIdempotencyWithMsSqlStore(services, connectionString, config) instead.
dknet-packages — start there to confirm this is the right package before wiring idempotency into a new project.dknet-aspcore-api — minimal-API endpoint conventions and start-up tasks (DKNet.AspCore.Extensions, DKNet.AspCore.Tasks) this filter sits alongside.dknet-core-utilities — DKNet.Fw.Extensions supplies IsRegistered<T>(), the first-wins DI guard every Add...Store extension in this family uses.dknet-testing — TestContainers fixtures (MsSql/Postgres/Redis), the ARM64 exclusion rule for MsSql-backed tests, and general testing patterns for code built on DKNet.IdempotencyOptions, scope resolution, conflict handling, the in-process dev store.dotnet ef tooling.dotnet ef tooling.Docs: https://baoduy.github.io/DKNet/ · NuGet: https://www.nuget.org/packages/DKNet.AspCore.Idempotency (and the .Relational/.MsSqlStore/.NpgsqlStore/.RedisStore siblings) · each reference file's header table links that package's own docs page under github.com/baoduy/DKNet/blob/dev/docs/AspNetCore/.
references/DKNet.AspCore.Idempotency.MsSqlStore.md (opens in a new tab)references/DKNet.AspCore.Idempotency.NpgsqlStore.md (opens in a new tab)references/DKNet.AspCore.Idempotency.RedisStore.md (opens in a new tab)references/DKNet.AspCore.Idempotency.Relational.md (opens in a new tab)references/DKNet.AspCore.Idempotency.md (opens in a new tab)references/diagnostics.md (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
Other plugins' skills for the same job
npx claudepluginhub baoduy/dknet --plugin dknet-skills13 skills in this plugin
/dknet-aspcore-apiCovers DKNet.AspCore.Extensions and DKNet.AspCore.Tasks. Use when writing an IEndpointConfig group, calling UseEndpointConfigs for minimal-API endpoint discovery and DKNet API versioning, mapping verbs with MapGet/MapPost/MapPut/MapPatch/MapDelete/MapPutById/MapActionById/MapParameterlessActionById, building a generic list endpoint with MapGetList/MapGetById/MapDeleteById plus PagedResponse and ListFilter, converting a FluentResults Result to ProblemDetails via .Response()/.Response<T>() or AddErrorResponses, scoping authorization per verb with [EndpointGroupScope], populating [FromClaim]/[FromRequestHeader] members via AddContextualRequestPopulation, or registering IBackgroundTask with AddBackgroundJob/AddBackgroundJobFrom to run work once at host start-up./dknet-blob-storageCovers DKNet.Svc.BlobStorage.Abstractions, the .NET blob storage abstraction (IBlobService, BlobService, BlobRequest, BlobDetails.BlobData/BlobStreamData/BlobResult/BlobDataResult, BlobServiceOptions), plus its three providers: DKNet.Svc.BlobStorage.Local (AddLocalDirectoryBlobService, path-traversal-safe filesystem storage), DKNet.Svc.BlobStorage.AwsS3 (AddS3BlobService, AWS S3 and S3-compatible endpoints like MinIO and Cloudflare R2), and DKNet.Svc.BlobStorage.AzureStorage (AddAzureStorageAdapter, managed identity, SAS URLs). Use to upload, download, list, or delete files; wire DI/IConfiguration binding; generate a public or SAS URL; stream a large upload without buffering; test with Azurite or MinIO containers; or debug FileLoadException, InvalidOperationException, UnauthorizedAccessException path-traversal, or a GetAsync miss that throws on Local but returns null on S3/Azure./dknet-codegenCovers DKNet.EfCore.DtoGenerator's [GenerateDto(typeof(Entity))] generator (Include/Exclude/IgnoreComplexType, DtoGeneratorExclusions, DtoGeneratorIgnoreComplexType, DKDTOGEN001-005) plus its RaisesEventValidator for [RaisesEvent] (DKRAISEVT001-011); and DKNet.SlimBus.Generators' CrudGenerator, turning [CrudCreate]/[CrudUpdate]/[CrudAction] (DKNet.EfCore.Abstractions.Attributes) into request records, IHandler<,> implementations and Map{Entity}Crud endpoints (DKCRUDGEN001-010). Use when a source generator is not generating, a build reports a duplicate type generated, a generated request/handler/endpoint is missing, EmitCompilerGeneratedFiles is needed for .g.cs output, or before hand-writing what an attribute already emits. Also clarifies [FromClaim] is not a generator — it's runtime model binding in DKNet.AspCore.Extensions.ModelBinding (see dknet-aspcore-api)./dknet-core-utilitiesCovers DKNet.Fw.Extensions and DKNet.RandomCreator, the two dependency-light Core packages DKNet builds on. Fw.Extensions gives GetPropertyValue/SetPropertyValue/TrySetPropertyValue by dotted property path, IsImplementOf for open-generic type checks, TryConvertToEnum, enum [Display] attribute name lookup via GetEnumInfos<T>(), IsRegistered<T>()/IsRegisteredWithImplementation<T>() DI guards on IServiceCollection, and the lazy TypeExtractors assembly scanner to scan assemblies for types, e.g. Extract().Abstract().Publics() or Extract().Classes().NotAbstract().IsInstanceOf<T>(). RandomCreator gives RandomCreators.NewString/NewChars, a CSPRNG-only generator with StringCreatorOptions MinNumbers/MinSpecials exact quotas, to generate a secure password, token, or one-time code. Use when reading or writing object fields by name, checking an open-generic implementation, guarding a duplicate DI registration, converting a loose value to an enum, or generating a secure random string./dknet-efcore-data-securityCovers DKNet.EfCore.DataAuthorization and DKNet.EfCore.Encryption. DataAuthorization gives a multi-tenant row filter over IOwnedBy entities via IDataOwnerProvider and IDataOwnerDbContext.AccessibleKeys, wired with AddDataOwnerProvider<TDbContext,TProvider>; the global query filter fails closed (empty AccessibleKeys denies, not allows) and a SaveChanges hook stamps OwnedBy. Encryption encrypts a column transparently by marking a string property [Encrypted], registering AddEfCoreEncryption<TKeyProvider> plus an IEncryptionKeyProvider, then calling modelBuilder.UseColumnEncryption — a ValueConverter encryption pipeline producing an AES-GCM column with a random IV per write. Use this for tenant isolation EF Core wiring, rows leaking across tenants, an InvalidOperationException from UseColumnEncryption or DataOwnerAuthQuery, or key-rotation and IColumnEncryptionProvider questions./dknet-efcore-domain-modelCovers DKNet.EfCore.Abstractions, DKNet.EfCore.Extensions and DKNet.EfCore.Relational.Helpers: Entity<TKey>/Entity/AuditedEntity base classes, IConcurrencyEntity/ISoftDeletableEntity, GUID v7 keys, and the [RaisesEvent] declaration, [Sequence]/[SqlSequence], [AuditLog]/[SensitiveData] attributes; UseAutoConfigModel, IEntityTypeConfiguration discovery via DefaultEntityTypeConfiguration, global query filter (GlobalQueryFilter), data seeding, SQL sequences (NextSeqValue), SnapshotContext, SaveChangesWithConcurrencyHandlingAsync, role-aware [SensitiveData] JSON, and CreateTableAsync/TableExistsAsync for schema work outside migrations. Use when modeling an entity or aggregate, wiring DbContext model discovery, adding a concurrency token or soft delete, seeding reference data, generating sequence-backed codes, or provisioning a table without a migration.