Rask.SQLite
0.20.0
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
<PackageReference Include="Rask.SQLite" Version="0.20.0" />
<PackageVersion Include="Rask.SQLite" Version="0.20.0" />
<PackageReference Include="Rask.SQLite" />
paket add Rask.SQLite --version 0.20.0
#r "nuget: Rask.SQLite, 0.20.0"
#:package Rask.SQLite@0.20.0
#addin nuget:?package=Rask.SQLite&version=0.20.0
#tool nuget:?package=Rask.SQLite&version=0.20.0
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.Sqlitepools connections and the per-connection pragmas don't persist, so they are re-applied each time a connection opens (aStateChangehook on the factory's connections; the EF Core package uses aConnectionOpenedinterceptor). Onlyjournal_mode=WALpersists in the database file header. - Fully overridable / opt-outable. Set any option to
nullto leave that pragma at SQLite's own default.
Full documentation: https://github.com/pal-tamas/rask/blob/main/docs/sqlite.md
| Product | Versions 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. |
-
net10.0
- Microsoft.Data.Sqlite (>= 10.0.10)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.10)
- SQLitePCLRaw.bundle_e_sqlite3 (>= 3.0.5)
- SQLitePCLRaw.core (>= 3.0.5)
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 | 0 | 8/19/2026 |
| 0.20.1-alpha.0.102 | 0 | 8/19/2026 |
| 0.20.1-alpha.0.101 | 0 | 8/19/2026 |
| 0.20.1-alpha.0.100 | 0 | 8/19/2026 |
| 0.20.1-alpha.0.98 | 0 | 8/19/2026 |
| 0.20.1-alpha.0.97 | 0 | 8/19/2026 |
| 0.20.1-alpha.0.96 | 0 | 8/19/2026 |
| 0.20.1-alpha.0.94 | 0 | 8/19/2026 |
| 0.20.1-alpha.0.93 | 32 | 8/18/2026 |
| 0.20.1-alpha.0.88 | 29 | 8/18/2026 |
| 0.20.1-alpha.0.87 | 21 | 8/18/2026 |
| 0.20.1-alpha.0.86 | 27 | 8/18/2026 |
| 0.20.1-alpha.0.83 | 26 | 8/18/2026 |
| 0.20.1-alpha.0.82 | 31 | 8/18/2026 |
| 0.20.1-alpha.0.81 | 27 | 8/18/2026 |
| 0.20.1-alpha.0.79 | 34 | 8/18/2026 |
| 0.20.1-alpha.0.78 | 36 | 8/18/2026 |
| 0.20.1-alpha.0.77 | 25 | 8/18/2026 |
| 0.20.1-alpha.0.76 | 28 | 8/18/2026 |
| 0.20.0 | 388 | 8/6/2026 |