Rig.TUnit.Databases.Sql.Sqlite
0.1.0-beta.2
dotnet add package Rig.TUnit.Databases.Sql.Sqlite --version 0.1.0-beta.2
NuGet\Install-Package Rig.TUnit.Databases.Sql.Sqlite -Version 0.1.0-beta.2
<PackageReference Include="Rig.TUnit.Databases.Sql.Sqlite" Version="0.1.0-beta.2" />
<PackageVersion Include="Rig.TUnit.Databases.Sql.Sqlite" Version="0.1.0-beta.2" />
<PackageReference Include="Rig.TUnit.Databases.Sql.Sqlite" />
paket add Rig.TUnit.Databases.Sql.Sqlite --version 0.1.0-beta.2
#r "nuget: Rig.TUnit.Databases.Sql.Sqlite, 0.1.0-beta.2"
#:package Rig.TUnit.Databases.Sql.Sqlite@0.1.0-beta.2
#addin nuget:?package=Rig.TUnit.Databases.Sql.Sqlite&version=0.1.0-beta.2&prerelease
#tool nuget:?package=Rig.TUnit.Databases.Sql.Sqlite&version=0.1.0-beta.2&prerelease
Rig.TUnit.Databases.Sql.Sqlite
In-memory shared-cache SQLite provider — the zero-container fast path for tests that need real SQL semantics.
What this package is
The fast-path SQL provider. SqliteFixture opens a connection to
Data Source=file::memory:?cache=shared (or a file on disk when isolation
demands it) and holds it open for the fixture's lifetime so the in-memory
database persists across DbContext disposals. No container, no Docker,
no pull — tests using SQLite finish in tens of milliseconds.
Still participates in Rig.TUnit.Databases.Sql's family contract so the
same parity assertions run against SQLite as against the container-backed
providers.
When to use it
- Fast feedback loops where container startup cost dominates.
- Running the family contract on a machine without Docker.
- Verifying EF Core LINQ translation is legal across providers.
- Not for: features SQLite does not support —
DbType.RowVersion, schema-aware queries, stored procedures,FOR JSON, full-text search beyond the FTS5 extension. Use a real Postgres/SqlServer for those.
Prerequisites
- .NET 10 SDK
Microsoft.EntityFrameworkCore.Sqlite10.x (transitive)
Quick start
using Microsoft.EntityFrameworkCore;
using Rig.TUnit.Databases.Sql.Sqlite.Fixtures;
await using var fx = new SqliteFixture();
await fx.InitializeAsync();
var opts = new DbContextOptionsBuilder<TestDb>()
.UseSqlite(fx.Connection)
.Options;
Options
| Property | Type | Default | Description |
|---|---|---|---|
Mode |
SqliteMode |
SharedCacheMemory |
SharedCacheMemory / FilePath / PrivateCacheMemory |
FilePath |
string? |
null |
Only used when Mode == FilePath |
EnableForeignKeys |
bool |
true |
PRAGMA foreign_keys = ON |
JournalMode |
string |
"WAL" |
WAL / DELETE / MEMORY |
Fixture + helper APIs
Rig.TUnit.Databases.Sql.Sqlite.Fixtures.SqliteFixtureRig.TUnit.Databases.Sql.Sqlite.Options.SqliteFixtureOptionsRig.TUnit.Databases.Sql.Sqlite.Builder.SqliteRigBuilderUseSqlite(RigBuilder, …)extension
Per-test isolation
SQLite in-memory is isolated by the fixture owning its open connection —
drop the fixture, the DB is gone. For file-mode, the file name includes
IsolationKey so parallel tests do not collide.
Parallelism + performance
- Zero startup (no container).
- Per-test DbContext: ~5 ms.
- Safe under full parallelism — each fixture owns its own connection; no cross-test state.
Troubleshooting
SQLite Error 19: 'FOREIGN KEY constraint failed'— defaults to ON in the fixture; older codebases assuming OFF will see new failures. SetEnableForeignKeys = falseif intentional.- Data disappears between tests — the connection was closed; ensure
the fixture's connection is the one
DbContextuses, not a new one.
See docs/troubleshooting.md#sqlite.
Provider quirks + edge cases
- SQLite is dynamically typed —
decimalround-trip precision is lossy; useTEXTstorage (HasConversion<string>()) for money. - No schemas;
[Table("dbo.Orders")]translates to"dbo.Orders"(literal identifier with dot), not a schema-qualified name. DATETIMEis stored as TEXT ISO-8601 by default; timezone round-trip loses tzinfo unless you useDateTimeOffset.
Benchmarks
See SqliteBenchmarks.cs;
baseline in benchmarks/baseline-005.json. SQLite is the family's
speed-of-light reference.
Related docs
License
MIT. See LICENSE.
| 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
- Bogus (>= 35.6.1)
- Microsoft.Data.Sqlite (>= 10.0.0)
- Microsoft.EntityFrameworkCore (>= 10.0.0)
- Microsoft.EntityFrameworkCore.InMemory (>= 10.0.0)
- Microsoft.EntityFrameworkCore.Relational (>= 10.0.0)
- Microsoft.EntityFrameworkCore.Sqlite (>= 10.0.0)
- Microsoft.Extensions.Caching.Abstractions (>= 10.0.0)
- Microsoft.Extensions.Caching.Memory (>= 10.0.0)
- Microsoft.Extensions.Configuration (>= 10.0.0)
- Microsoft.Extensions.Configuration.Binder (>= 10.0.0)
- Microsoft.Extensions.DependencyInjection (>= 10.0.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.0)
- Microsoft.Extensions.Logging (>= 10.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.0)
- Microsoft.Extensions.Options (>= 10.0.0)
- Microsoft.Extensions.Options.DataAnnotations (>= 10.0.0)
- Rig.TUnit.Databases.Sql (>= 0.1.0-beta.2)
- TUnit.Core (>= 1.34.5)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Rig.TUnit.Databases.Sql.Sqlite:
| Package | Downloads |
|---|---|
|
Rig.TUnit.All
Meta-package containing every Rig.TUnit.* package. DISCOURAGED — prefer per-feature or per-stack meta-packages (Rig.TUnit, Rig.TUnit.Microservices). |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.1.0-beta.2 | 45 | 4/27/2026 |
| 0.0.0-alpha.0.14 | 46 | 4/26/2026 |