Rig.TUnit.Databases.Sql.SqlServer
0.1.0-beta.2
dotnet add package Rig.TUnit.Databases.Sql.SqlServer --version 0.1.0-beta.2
NuGet\Install-Package Rig.TUnit.Databases.Sql.SqlServer -Version 0.1.0-beta.2
<PackageReference Include="Rig.TUnit.Databases.Sql.SqlServer" Version="0.1.0-beta.2" />
<PackageVersion Include="Rig.TUnit.Databases.Sql.SqlServer" Version="0.1.0-beta.2" />
<PackageReference Include="Rig.TUnit.Databases.Sql.SqlServer" />
paket add Rig.TUnit.Databases.Sql.SqlServer --version 0.1.0-beta.2
#r "nuget: Rig.TUnit.Databases.Sql.SqlServer, 0.1.0-beta.2"
#:package Rig.TUnit.Databases.Sql.SqlServer@0.1.0-beta.2
#addin nuget:?package=Rig.TUnit.Databases.Sql.SqlServer&version=0.1.0-beta.2&prerelease
#tool nuget:?package=Rig.TUnit.Databases.Sql.SqlServer&version=0.1.0-beta.2&prerelease
Rig.TUnit.Databases.Sql.SqlServer
Testcontainers-backed SQL Server fixture using the
mcr.microsoft.com/mssql/server:2022-latestimage, integrated withMicrosoft.EntityFrameworkCore.SqlServer.
What this package is
The Rig.TUnit SQL Server provider. SqlServerFixture spins the Microsoft
2022 Developer-edition container via Testcontainers and exposes a ready
ConnectionString. Integrates with the Rig.TUnit.Databases.Sql family
base for parity assertions and with EF Core via the standard
UseSqlServer(connectionString) wire.
When to use it
- Integration tests targeting SqlServer-specific features (
OUTPUT INTO, temporal tables,MERGE, rowversion). - Multi-engine tests where SqlServer is a required matrix cell.
- Verifying migration scripts before deploy.
- Not for: unit tests — prefer SQLite in-memory.
Prerequisites
- .NET 10 SDK
- Docker Desktop / Colima (first pull ~1.5 GB)
- Linux or Windows-containers-enabled Docker daemon.
Quick start
using Microsoft.EntityFrameworkCore;
using Rig.TUnit.Databases.Sql.SqlServer.Fixtures;
await using var fx = new SqlServerFixture();
await fx.InitializeAsync();
var opts = new DbContextOptionsBuilder<TestDb>()
.UseSqlServer(fx.ConnectionString)
.Options;
Options
| Property | Type | Default | Description |
|---|---|---|---|
Image |
string |
"mcr.microsoft.com/mssql/server:2022-latest" |
Container image |
StartupTimeoutSeconds |
int |
180 |
SqlServer takes ~30-60s to warm |
SaPassword |
string |
"RigTUnit_P@ss1" |
SA password — must satisfy policy |
AcceptEula |
bool |
true |
Sets ACCEPT_EULA=Y |
Edition |
string |
"Developer" |
Express / Developer / Standard / Enterprise |
Fixture + helper APIs
Rig.TUnit.Databases.Sql.SqlServer.Fixtures.SqlServerFixtureRig.TUnit.Databases.Sql.SqlServer.Options.SqlServerFixtureOptionsRig.TUnit.Databases.Sql.SqlServer.Builder.SqlServerRigBuilderUseSqlServer(RigBuilder, …)extension
Per-test isolation
Default is one container per fixture class; per-test DB isolation via
CREATE DATABASE test_{IsolationKey} + DROP DATABASE in the Arrange /
teardown pair. For heavy use, one fixture per test-class is typical — full
per-test containers are cost-prohibitive for SqlServer's warm-up time.
Parallelism + performance
- First-run pull: ~60–90 s (~1.5 GB).
- Warm startup: ~30–60 s.
- Per-test DB create + drop: ~150 ms.
- Parallelism: cap at 4 unless your host has >16 GB RAM allocated to Docker — each container reserves ~2 GB.
Troubleshooting
The SA password does not meet SQL Server password policy— password must have 8+ chars + upper + lower + digit + symbol. The defaultRigTUnit_P@ss1satisfies this; override carefully.- Container OOM — SqlServer's default memory target is 80 % of host;
limit via
-e MSSQL_MEMORY_LIMIT_MB=2048in the Testcontainers config. Login failed for user 'sa'— ephemeral container health-check reports ready beforesalogin is enabled. Fixture waits for a successfulSELECT 1before returning, so normal calls are safe.
See docs/troubleshooting.md#sqlserver.
Provider quirks + edge cases
rowversion/timestampis a binary concurrency token — EF maps it tobyte[]but reportsDataType=Binary; useIsConcurrencyToken()inOnModelCreating.- Max identifier length is 128 chars — longest in the SQL family.
- Case folding: default collation is
SQL_Latin1_General_CP1_CI_AS(case INsensitive). Tests relying on exact case must use a case-sensitive collation.
Benchmarks
See SqlServerBenchmarks.cs;
baseline in benchmarks/baseline-005.json.
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.EntityFrameworkCore (>= 10.0.0)
- Microsoft.EntityFrameworkCore.InMemory (>= 10.0.0)
- Microsoft.EntityFrameworkCore.Relational (>= 10.0.0)
- Microsoft.EntityFrameworkCore.SqlServer (>= 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)
- Microsoft.IdentityModel.JsonWebTokens (>= 8.3.0)
- Microsoft.IdentityModel.Tokens (>= 8.3.0)
- Rig.TUnit.Databases.Sql (>= 0.1.0-beta.2)
- System.IdentityModel.Tokens.Jwt (>= 8.3.0)
- Testcontainers (>= 4.11.0)
- Testcontainers.MsSql (>= 4.11.0)
- TUnit.Core (>= 1.34.5)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Rig.TUnit.Databases.Sql.SqlServer:
| 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 | 42 | 4/27/2026 |
| 0.0.0-alpha.0.14 | 52 | 4/26/2026 |