Rask.SqlServer 0.20.0

There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package Rask.SqlServer --version 0.20.0
                    
NuGet\Install-Package Rask.SqlServer -Version 0.20.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="Rask.SqlServer" Version="0.20.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Rask.SqlServer" Version="0.20.0" />
                    
Directory.Packages.props
<PackageReference Include="Rask.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 Rask.SqlServer --version 0.20.0
                    
#r "nuget: Rask.SqlServer, 0.20.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 Rask.SqlServer@0.20.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=Rask.SqlServer&version=0.20.0
                    
Install as a Cake Addin
#tool nuget:?package=Rask.SqlServer&version=0.20.0
                    
Install as a Cake Tool

Rask.SqlServer

SQL Server for a Rask app. UseRaskSqlServer(...) is a drop-in replacement for UseSqlServer that also wires a ConnectionOpened interceptor applying the production session settings — SET LOCK_TIMEOUT, SET XACT_ABORT ON — to every connection the context opens, sets a client command timeout, and turns on transient-failure retrying.

SQLite remains Rask's default, and for most single-developer products it is the right answer for a long time. This package is for the case where SQL Server is already the house database.

Install

dotnet add package Rask.SqlServer

Or scaffold a project that already uses it:

rask new Shop --data --database sqlserver

Use

builder.Services.AddDbContextFactory<AppDb>(o =>
    o.UseRaskSqlServer(builder.Configuration.GetConnectionString("App")!));

Override any default via the optional configure delegate:

o.UseRaskSqlServer(connectionString, p =>
{
    p.CommandTimeout = TimeSpan.FromSeconds(10);
    p.LockTimeout = TimeSpan.FromSeconds(3);
    p.AbortOnError = false;
});

What the defaults do

Setting Default Why
CommandTimeout 30s SQL Server has no server-side statement timeout, so this client-side ceiling is the only bound on a runaway query.
LockTimeout 10s The analogue of SQLite's busy_timeout. Without it, a statement stuck behind a lock waits out the command timeout and surfaces as a slow query — so you go reading query plans instead of finding what holds the lock.
AbortOnError true SET XACT_ABORT ON. With it off, a statement error inside an explicit transaction leaves that transaction open and holding locks until something rolls it back — and on a web app the connection returns to the pool in that state.
MaxRetryCount / MaxRetryDelay 6 / 30s SQL Server's own EnableRetryOnFailure, which already knows the transient error numbers including the Azure SQL failover set.

LockTimeout is validated to sit below CommandTimeout; above it the client gives up first and the lock signal is lost. Set LockTimeout to TimeSpan.Zero to wait indefinitely (the server default).

Not a mirror of Rask.Postgres

Deliberately. SQL Server has no server-side statement timeout and nothing corresponding to idle_in_transaction_session_timeout, so neither is invented here; what it does have, and PostgreSQL does not need, is XACT_ABORT. The two packages match in shape, not in knobs.

What stays behind

Litestream continuous backup and file snapshots (Rask.SQLite.Litestream, Rask.SQLite.Snapshots) are SQLite-only by definition — they replicate and copy a file. On SQL Server, backup is BACKUP DATABASE or your provider's snapshots; rask db backup will tell you so rather than pretend. rask db add / rask db update work unchanged, because they forward to dotnet ef.

See docs/databases.md for the full picture, including what changes when you run more than one instance.

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
0.20.1-alpha.0.43 5 8/12/2026
0.20.1-alpha.0.42 29 8/12/2026
0.20.1-alpha.0.41 32 8/12/2026
0.20.1-alpha.0.40 25 8/12/2026
0.20.1-alpha.0.38 31 8/12/2026
0.20.1-alpha.0.36 56 8/10/2026
0.20.1-alpha.0.18 43 8/8/2026
0.20.1-alpha.0.17 47 8/8/2026
0.20.1-alpha.0.16 44 8/8/2026
0.20.1-alpha.0.15 50 8/7/2026
0.20.1-alpha.0.14 53 8/7/2026
0.20.1-alpha.0.13 45 8/7/2026
0.20.1-alpha.0.12 40 8/7/2026
0.20.1-alpha.0.11 49 8/7/2026
0.20.1-alpha.0.9 39 8/7/2026
0.20.1-alpha.0.8 55 8/7/2026
0.20.1-alpha.0.7 50 8/7/2026
0.20.1-alpha.0.5 53 8/7/2026
0.20.1-alpha.0.4 44 8/7/2026
0.20.0 46 8/6/2026
Loading failed