IdempotencyGuard.SqlServer 1.3.0

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

IdempotencyGuard.SqlServer

SQL Server-backed idempotency store for the IdempotencyGuard library. Uses MERGE with HOLDLOCK for atomic claim operations and supports automatic schema provisioning.

Installation

dotnet add package IdempotencyGuard.AspNetCore
dotnet add package IdempotencyGuard.SqlServer

Setup

var builder = WebApplication.CreateBuilder(args);

builder.Services.AddIdempotencyGuard(options =>
{
    options.MissingKeyPolicy = MissingKeyPolicy.Reject;
});

builder.Services.AddIdempotencyGuardSqlServerStore(options =>
{
    options.ConnectionString = "Server=localhost;Database=myapp;Trusted_Connection=true";
    options.TableName = "IdempotencyEntries";  // default
    options.AutoCreateTable = true;            // creates table on first use
});

var app = builder.Build();
app.UseIdempotencyGuard();

How it works

  • ClaimMERGE with HOLDLOCK for atomic upsert with fingerprint validation
  • CompleteUPDATE to store the response body, headers, and status code
  • ReleaseDELETE to remove the claim after processing failure
  • Cleanup — Batched DELETE TOP operations via the background cleanup service

Schema

When AutoCreateTable = true, the store creates the following table on first use:

CREATE TABLE [IdempotencyEntries] (
    [Key]            NVARCHAR(256)  NOT NULL PRIMARY KEY,
    RequestFingerprint NVARCHAR(128)  NOT NULL,
    State            NVARCHAR(20)   NOT NULL,
    ClaimedAtUtc     DATETIME2      NOT NULL,
    CompletedAtUtc   DATETIME2      NULL,
    ExpiresAtUtc     DATETIME2      NOT NULL,
    StatusCode       INT            NULL,
    HeadersJson      NVARCHAR(MAX)  NULL,
    ResponseBody     VARBINARY(MAX) NULL
);

Expired entry cleanup

Expired entries are purged by the built-in background service. Configure the cleanup interval and batch size:

builder.Services.AddIdempotencyGuard(options =>
{
    options.Cleanup.Interval = TimeSpan.FromMinutes(5);
    options.Cleanup.BatchSize = 1_000;
});

Documentation

See the full documentation on GitHub for middleware configuration, selective fingerprinting, and production deployment guides.

License

MIT

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  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
1.3.0 98 4/26/2026
1.2.4 110 4/3/2026
1.2.3 105 3/18/2026
1.2.2 103 3/10/2026
1.2.1 99 3/10/2026
1.2.0 108 3/10/2026
1.1.0 106 3/10/2026
1.0.0 101 3/7/2026