Rig.TUnit.Databases.Sql.MySql
0.1.0-beta.2
dotnet add package Rig.TUnit.Databases.Sql.MySql --version 0.1.0-beta.2
NuGet\Install-Package Rig.TUnit.Databases.Sql.MySql -Version 0.1.0-beta.2
<PackageReference Include="Rig.TUnit.Databases.Sql.MySql" Version="0.1.0-beta.2" />
<PackageVersion Include="Rig.TUnit.Databases.Sql.MySql" Version="0.1.0-beta.2" />
<PackageReference Include="Rig.TUnit.Databases.Sql.MySql" />
paket add Rig.TUnit.Databases.Sql.MySql --version 0.1.0-beta.2
#r "nuget: Rig.TUnit.Databases.Sql.MySql, 0.1.0-beta.2"
#:package Rig.TUnit.Databases.Sql.MySql@0.1.0-beta.2
#addin nuget:?package=Rig.TUnit.Databases.Sql.MySql&version=0.1.0-beta.2&prerelease
#tool nuget:?package=Rig.TUnit.Databases.Sql.MySql&version=0.1.0-beta.2&prerelease
Rig.TUnit.Databases.Sql.MySql
Testcontainers-backed MySQL fixture using the official
mysql:8.4image, withMySqlConnectorraw access and Pomelo EF Core extensions.
What this package is
A production-shape MySQL test fixture. MySqlFixture spins the official
mysql image via Testcontainers, waits for readiness via socket-connect,
and exposes ConnectionString / Database for raw MySqlConnector use or
any EF Core provider the caller installs. Integrates with the
Rig.TUnit.Databases.Sql family contract for cross-engine parity testing.
When to use it
- Integration tests targeting MySQL-specific features (full-text search,
spatial indexes,
JSON_TABLE). - Multi-engine tests where one matrix cell runs against MySQL.
- Verifying Pomelo EF Core behaviour against a real server.
- Not for: pure domain unit tests — use SQLite-in-memory instead.
Prerequisites
- .NET 10 SDK
- Docker Desktop / Colima (pulls
mysql:8.4, ~600 MB first pull) - If testing EF Core: Pomelo.EntityFrameworkCore.MySql (caller installs)
Quick start
using MySqlConnector;
using Rig.TUnit.Databases.Sql.MySql.Fixtures;
await using var fx = new MySqlFixture();
await fx.InitializeAsync();
await using var conn = new MySqlConnection(fx.ConnectionString);
await conn.OpenAsync();
Options
| Property | Type | Default | Description |
|---|---|---|---|
ImageTag |
string |
"8.4" |
MySQL Docker image tag |
StartupTimeoutSeconds |
int |
180 |
MySQL init can be slow on first pull |
Username |
string |
"root" |
Default container user |
Password |
string |
"rigtunit" |
Root password |
Database |
string |
"rigtunit" |
Default database created on startup |
Fixture + helper APIs
Rig.TUnit.Databases.Sql.MySql.Fixtures.MySqlFixtureRig.TUnit.Databases.Sql.MySql.Options.MySqlFixtureOptionsRig.TUnit.Databases.Sql.MySql.Builder.MySqlRigBuilderUseMySql(RigBuilder, …)extension
Per-test isolation
Default strategy is one container per fixture (per-class isolation via
TUnit's default lifecycle). For per-test schema isolation, use
IsolationKey.FromExecutionContext() as the schema prefix and create it
in the test's Arrange step via CREATE SCHEMA IF NOT EXISTS.
Parallelism + performance
- First-run container pull: ~20–40 s (one-time per CI cache warmup).
- Warm startup: ~4–8 s (MySQL init is slower than Postgres).
- Per-test DbContext open: ~20 ms.
- Safe under full test parallelism at class granularity.
Troubleshooting
ReplaceDbContext<T>()throwsNotSupportedException— Pomelo EF Core 10 stable is pending (PR #2019). Install the prerelease or register yourDbContextmanually without the helper.- Port conflicts under heavy parallelism — Testcontainers allocates ephemeral host ports by default; ensure you are not pinning a fixed port.
See docs/troubleshooting.md#mysql.
Provider quirks + edge cases
- MySQL identifiers are case-insensitive by default on Windows containers; case-sensitive on Linux (most Testcontainers runs). Tests that depend on table-name casing must pin to Linux.
utf8mb4is the default charset; legacyutf8is an alias forutf8mb3and does not store full Unicode.- Pomelo's
ServerVersion.AutoDetectopens a connection at model-building time — provideServerVersion.Create(8, 4, 0, ServerType.MySql)in tests to keep build synchronous.
Benchmarks
See MySqlBenchmarks.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.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)
- MySqlConnector (>= 2.4.0)
- Rig.TUnit.Databases.Sql (>= 0.1.0-beta.2)
- Testcontainers (>= 4.11.0)
- Testcontainers.MySql (>= 4.11.0)
- TUnit.Core (>= 1.34.5)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Rig.TUnit.Databases.Sql.MySql:
| 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 | 44 | 4/27/2026 |
| 0.0.0-alpha.0.14 | 44 | 4/26/2026 |