Back to browse
GitHub Repository

InMemory C# Database for Unit Test (Mysql, SqlServer, Oracle, Postgree)

6 starsC#

Testing SQL logic without a real database

by chrisulson·Feb 28, 2026·1 point·1 comment

AI Analysis

●●SolidSolve My ProblemNiche Gem

Replaces slow TestContainers with dialect-specific in-memory SQL; fills real testing pain.

Strengths
  • Dialect emulation across 6 major providers means tests catch SQL-specific bugs early, not just at integration
  • Plugs into IDbConnection interface: Dapper and raw SQL code runs unchanged—zero refactor friction
  • Execution metrics (cost, selectivity, rows/ms) provide visibility into query behavior during tests, not just pass/fail
Weaknesses
  • In-memory SQL engines (SQLite in-memory, H2) already exist; author's rationale (dialect differences) applies narrowly
  • No evidence of production usage or comparison benchmarks vs TestContainers + real DB in CI/CD cost trade-off
Target Audience

C# backend engineers testing repository/data access layer code

Similar To

SQLite in-memory · H2 Database (Java) · Testcontainers

Post Description

Show HN: Testing SQL logic without a real database

Over the years I kept fighting the same problem when testing repository code:

real database tests are slow

Docker/TestContainers add friction and startup time

mocks don’t validate SQL behavior

SQLite introduces dialect differences

integration tests are too late for fast feedback

So I built an in-memory SQL engine focused on validating SQL behavior during unit tests.

It plugs into IDbConnection, allowing repository code (Dapper or raw SQL) to run unchanged.

What it does

emulates SQL dialect behavior

validates constraints and query logic

supports multiple providers (MySQL, SQL Server, PostgreSQL, Oracle, SQLite, DB2)

simulates version-specific behavior

provides execution metrics and plan insights

runs entirely in memory (no infrastructure)

The goal is not to replace integration tests.

It’s to catch SQL logic issues earlier and keep tests fast, deterministic, and portable.

Why not SQLite in-memory?

SQLite is great, but testing against it means testing SQLite semantics.

Teams often hit:

type mismatches

dialect drift

query compatibility differences

adaptation layers in test code

This approach keeps behavior aligned with the target database rules.

Current work

I’m working on tooling to reduce friction further:

Visual Studio & VS Code extensions

mapping tables, views, and procedures locally

generating in-memory schemas automatically

keeping test schemas aligned with real databases

Background

The core originated from a previous internal project and includes extensive compatibility tests to validate behavior across database versions and frameworks.

Looking for feedback

Curious how others handle SQL testing trade-offs.

If this problem space resonates with you, contributions and real-world scenarios are very welcome. The project is open source and evolving, and additional dialect behaviors, edge cases, and tooling improvements can make it more useful for everyone.

Repo: https://github.com/christianulson/DbSqlLikeMem Nuget: https://www.nuget.org/packages/DbSqlLikeMem

Similar Projects

Developer Tools●●Solid

Snowflake Emulator in Rust – Test locally without cloud credits

This actually implements a surprisingly large slice of Snowflake: VARIANT/ARRAY/OBJECT types, LATERAL FLATTEN, QUALIFY, MERGE, COPY, transactions and ~90 JSON/array/window functions — all exposed via Snowflake SQL API v2 and compatible with the Go driver so most clients can point at localhost. Running on DataFusion in Rust and shipped as a Docker image with testcontainers/GHA examples makes it immediately useful in CI; just remember it's an emulator, not Snowflake's full runtime, so you may hit edge-case behavioral differences.

Solve My ProblemWizardryNiche Gem
sivchari
203mo ago