DKNet

Register the SQL Server ledger

Part of DKNet.AspCore.Idempotency.MsSqlStore. IdempotencyMsSqlSetup provides two application entry points:

using DKNet.AspCore.Idempotency.MsSqlStore;
using Microsoft.Extensions.DependencyInjection;
var services = new ServiceCollection();
services.AddLogging();
var connection = Environment.GetEnvironmentVariable("ConnectionStrings__Idempotency")
    ?? throw new InvalidOperationException("Set ConnectionStrings__Idempotency.");
services.AddIdempotencyWithMsSqlStore(connection);

The host registers SQL Server infrastructure, then selects the internal provider store through the core registration.

Method Registers
AddIdempotencyMsSqlStore(string) Provider context, context factory, and startup migration service only.
AddIdempotencyWithMsSqlStore(string, Action<IdempotencyOptions>?) The infrastructure above, plus the internal IdempotencySqlServerStore as singleton IIdempotencyKeyStore.

The context is scoped, its options and factory are singleton, and each store operation creates its own context. The lower-level registration returns unchanged if its provider context is already registered; the first connection string therefore remains selected. Core store selection separately keeps the first explicit store, while allowing replacement of the in-memory default.

⚙️ Configuration reference

Input Type Default Effect
connectionString string required Database used for provider-owned migrations and ledger rows.
config Action<IdempotencyOptions>? null Configures core validation, scope, and retention.

There is no provider-specific options class. CachePrefix does not isolate relational rows.

🧱 Where it fits

The package overview shows the host registrations and dependencies behind this capability. The core filter and selected store have separate responsibilities.

The consumer host selects this package’s components and supplies the runtime dependencies shown in the package architecture.

⚠️ Gotchas & limits