Rig.TUnit.Databases.Sql.MySql 0.1.0-beta.2

This is a prerelease version of Rig.TUnit.Databases.Sql.MySql.
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
                    
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="Rig.TUnit.Databases.Sql.MySql" Version="0.1.0-beta.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Rig.TUnit.Databases.Sql.MySql" Version="0.1.0-beta.2" />
                    
Directory.Packages.props
<PackageReference Include="Rig.TUnit.Databases.Sql.MySql" />
                    
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 Rig.TUnit.Databases.Sql.MySql --version 0.1.0-beta.2
                    
#r "nuget: Rig.TUnit.Databases.Sql.MySql, 0.1.0-beta.2"
                    
#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 Rig.TUnit.Databases.Sql.MySql@0.1.0-beta.2
                    
#: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=Rig.TUnit.Databases.Sql.MySql&version=0.1.0-beta.2&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Rig.TUnit.Databases.Sql.MySql&version=0.1.0-beta.2&prerelease
                    
Install as a Cake Tool

Rig.TUnit.Databases.Sql.MySql

Testcontainers-backed MySQL fixture using the official mysql:8.4 image, with MySqlConnector raw 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.MySqlFixture
  • Rig.TUnit.Databases.Sql.MySql.Options.MySqlFixtureOptions
  • Rig.TUnit.Databases.Sql.MySql.Builder.MySqlRigBuilder
  • UseMySql(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>() throws NotSupportedException — Pomelo EF Core 10 stable is pending (PR #2019). Install the prerelease or register your DbContext manually 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.
  • utf8mb4 is the default charset; legacy utf8 is an alias for utf8mb3 and does not store full Unicode.
  • Pomelo's ServerVersion.AutoDetect opens a connection at model-building time — provide ServerVersion.Create(8, 4, 0, ServerType.MySql) in tests to keep build synchronous.

Benchmarks

See MySqlBenchmarks.cs; baseline in benchmarks/baseline-005.json.

License

MIT. See LICENSE.

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