Rask.SQLite 0.20.0

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

Rask.SQLite

Production-ready SQLite for .NET. Applies a tuned production pragma set — WAL journaling, synchronous=NORMAL, foreign_keys=ON, a busy_timeout, a shared mmap_size, and a capped journal_size_limit — to every SQLite connection, so your app gets correct, concurrent, production-ready SQLite by default instead of the lock-prone stock config.

Standalone and lean: it depends only on Microsoft.Data.Sqlite and is reflection-free, so it is fine under trimming/AOT and on mobile. You do not need the rest of Rask to use it.

Install

dotnet add package Rask.SQLite

Use

builder.Services.AddRaskSqlite($"Data Source={dbPath}");

// then inject IRaskSqliteConnectionFactory:
await using var connection = await factory.CreateOpenAsync(ct);   // pragmas already applied

The production defaults are on out of the box; override any of them:

builder.Services.AddRaskSqlite($"Data Source={dbPath}", p =>
{
    p.BusyTimeout = TimeSpan.FromSeconds(10);
    p.CacheSize = -20_000;              // negative ⇒ KiB, so 20 MB
    p.TempStore = SqliteTempStore.Memory;
});

Concurrent writes: IMMEDIATE transactions + a non-blocking retry

For the write path under concurrency, ExecuteInImmediateTransactionAsync runs your work in a BEGIN IMMEDIATE transaction and acquires the write lock through a non-blocking, fair-interval retry — a constant 1 ms poll that yields the thread while it waits (no blocked thread, no spurious database is locked):

await factory.ExecuteInImmediateTransactionAsync(async (connection, ct) =>
{
    await using var cmd = connection.CreateCommand();
    cmd.CommandText = "INSERT INTO WriteLogs (Note) VALUES ($note);";
    cmd.Parameters.AddWithValue("$note", note);
    await cmd.ExecuteNonQueryAsync(ct);
});

Tune it with AddRaskSqlite(cs, configureRetry: r => …) (defaults: 5 s timeout, 1 ms interval).

Your callback runs at least once, not exactly once: SQLite can roll a transaction back on its own when a contended COMMIT is answered with SQLITE_BUSY, and the whole transaction is then re-run because everything the callback wrote went with it. Keep the callback re-runnable and put side effects that must not repeat outside the transaction.

Using Entity Framework Core?

Add Rask.SQLite.EntityFrameworkCore for the one-line UseRaskSqlite(...) (a drop-in for UseSqlite that wires the pragma interceptor). It's a separate package so the pragma engine stays free of an EF Core dependency.

Defaults

Pragma Default
journal_mode WAL
synchronous NORMAL
foreign_keys ON
busy_timeout 5000 ms
cache_size 2000 pages
mmap_size 134217728 (128 MiB)
journal_size_limit 67108864 (64 MiB)
temp_store unset (opt-in MEMORY)

Notes

  • Applied on every open, not once at startup. Microsoft.Data.Sqlite pools connections and the per-connection pragmas don't persist, so they are re-applied each time a connection opens (a StateChange hook on the factory's connections; the EF Core package uses a ConnectionOpened interceptor). Only journal_mode=WAL persists in the database file header.
  • Fully overridable / opt-outable. Set any option to null to leave that pragma at SQLite's own default.

Full documentation: https://github.com/pal-tamas/rask/blob/main/docs/sqlite.md

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 (3)

Showing the top 3 NuGet packages that depend on Rask.SQLite:

Package Downloads
Rask.SQLite.EntityFrameworkCore

The Entity Framework Core integration for Rask.SQLite: `UseRaskSqlite(...)`, a drop-in replacement for `UseSqlite` that also registers a `ConnectionOpened` interceptor applying the production pragma set (WAL, `synchronous=NORMAL`, `foreign_keys=ON`, a `busy_timeout`, `mmap_size`, `journal_size_limit`) to every connection the context opens. Split out from Rask.SQLite so apps that only need the raw `Microsoft.Data.Sqlite` path (or run on mobile/AOT) don't pull in Entity Framework Core.

Rask.SQLite.Litestream

Supervises the Litestream sidecar from inside your .NET app: restores the SQLite database from its replica on startup (if the local file is missing) and continuously streams the write-ahead log to S3/GCS/Azure/file storage for the life of the process, via a hosted background service. Also verifies, on an opt-in schedule, that what has been replicated is actually restorable — a sentinel written locally, restored back out of the replica and checked — so you learn a backup has stopped working before the day you need it. Pairs with Rask.SQLite's WAL default, which Litestream requires. Register with `services.AddRaskSqliteLitestream(...)` and call `RestoreSqliteFromLitestreamAsync()` before opening the database. Requires the `litestream` binary on the host (or a path you configure).

Rask.Logging

A durable, queryable log store for a Rask app, kept in its own SQLite file — no agent, no hosted log service. Registers a standard `ILoggerProvider`, so it captures exactly what every other sink sees, buffers entries through a bounded channel that never blocks the caller, and writes them in batches on a background service. Retention is enforced by age and by row count, swept in short pages so the write lock is never held for long. Pairs with Rask.Dashboard, whose Logs page reads the store. Server-side; depends only on Microsoft.Data.Sqlite.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.20.1-alpha.0.103 9 8/19/2026
0.20.1-alpha.0.102 22 8/19/2026
0.20.1-alpha.0.101 26 8/19/2026
0.20.1-alpha.0.100 32 8/19/2026
0.20.1-alpha.0.98 34 8/19/2026
0.20.1-alpha.0.97 34 8/19/2026
0.20.1-alpha.0.96 28 8/19/2026
0.20.1-alpha.0.94 31 8/19/2026
0.20.1-alpha.0.93 45 8/18/2026
0.20.1-alpha.0.88 37 8/18/2026
0.20.1-alpha.0.87 29 8/18/2026
0.20.1-alpha.0.86 33 8/18/2026
0.20.1-alpha.0.83 35 8/18/2026
0.20.1-alpha.0.82 39 8/18/2026
0.20.1-alpha.0.81 33 8/18/2026
0.20.1-alpha.0.79 42 8/18/2026
0.20.1-alpha.0.78 44 8/18/2026
0.20.1-alpha.0.77 30 8/18/2026
0.20.1-alpha.0.76 37 8/18/2026
0.20.0 414 8/6/2026
Loading failed