Promotion I made a tool that gives each test its own full-size SQL Server database in a couple of seconds
The problem I wanted to fix: integration tests against SQL Server either run on a tiny seed that looks nothing like production, or on a shared database everyone keeps breaking. Restoring a real backup per test run is way too slow once it's tens of GB.
So I built SqlBranch. You restore a backup once into an "image" (and run your masking scripts on it), then every test, PR or dev gets a writable branch of it in a couple of seconds. Branches are copy-on-write clones of the database files (XFS reflink), so they share blocks with the image and only copy what you change. On a 50 GB database, the clone takes about 0.4 s and a new branch is ~300 KB on disk. It never touches your production server, just a backup file.
From a test it's one line:
await using var db = await SqlBranchDatabase.CreateAsync("shop");
// db.ConnectionString -> your own copy, dropped when the test endsWorks with xUnit, NUnit and MSTest (SqlBranch.Testing on NuGet). The CLI is a dotnet tool:
dotnet tool install --global SqlBranch
sqlbranch init
sqlbranch image build shop --from-bak ./shop.bak --post-script mask.sql
sqlbranch branch create my-feature --from shop"Why not Testcontainers?" I got this a lot already. If an empty DB + EF migrations + a small seed is enough, Testcontainers is great and you don't need this. SqlBranch is for when you want real data volume: catching a migration that breaks on old NULLs or duplicates, or a query that's fine on 20 rows and slow on 20 million.
Some honest limits: it's dev/test only (SQL Server Developer edition in Docker). Linux and macOS work, Windows isn't tested yet. In CI you need a runner where the image lives, since rebuilding it every job would defeat the point.
Open source, Apache-2.0: https://github.com/vuglll/SqlBranch
Curious what you think, especially what would stop you from using it.