![]() |
VOOZH | about |
dotnet add package Net4x.DapperLibrary.MockSqlServer --version 1.9.9.8
NuGet\Install-Package Net4x.DapperLibrary.MockSqlServer -Version 1.9.9.8
<PackageReference Include="Net4x.DapperLibrary.MockSqlServer" Version="1.9.9.8" />
<PackageVersion Include="Net4x.DapperLibrary.MockSqlServer" Version="1.9.9.8" />Directory.Packages.props
<PackageReference Include="Net4x.DapperLibrary.MockSqlServer" />Project file
paket add Net4x.DapperLibrary.MockSqlServer --version 1.9.9.8
#r "nuget: Net4x.DapperLibrary.MockSqlServer, 1.9.9.8"
#:package Net4x.DapperLibrary.MockSqlServer@1.9.9.8
#addin nuget:?package=Net4x.DapperLibrary.MockSqlServer&version=1.9.9.8Install as a Cake Addin
#tool nuget:?package=Net4x.DapperLibrary.MockSqlServer&version=1.9.9.8Install as a Cake Tool
Lightweight helpers to create and use a mocked SQL Server IDapperContext for tests and local development. This project provides a small framework around LocalDB (and optional Docker-based SQL Server containers on modern runtimes) to obtain IDapperContext instances backed by a file-based or ephemeral SQL Server instance.
Make it easy to spin up a disposable or reusable SQL Server instance for unit and integration tests and to obtain a corresponding IDapperContext preconfigured with SQL Server defaults used by the DapperLibraries.
.mdf database and return a configured IDapperContext.ReuseDb flag to speed test runs.NET6_0_OR_GREATER compilation.DatabaseModel defaults for SQL Server (identity initializer and datetime literal formatting).MockedSqlDapperContext / MockedSqlDapperContext<TSqlDapperContext>
MockedSqlUseDapperContext instance.GetInstance() overloads to obtain a ready-to-use IDapperContext (optionally accepting a logger and a custom path).Use() and UseOnce() methods that populate the global DapperContextFactory ContextCreator so application code can request contexts via factory APIs.IDisposable / IAsyncDisposable to release Docker containers.MockedSqlUseDapperContext
MockedSqlDapperContext to provision LocalDB instances or to fall back to Docker containers when requested.ReuseDb, UseMaster and UseDocker to modify provisioning behavior.LocalDbEnsurerInternal<T> and LocalDbInternal<T>
.mdf files, attaching/detaching databases, and returning an opened SqlConnection or IDapperContext rooted at the LocalDB instance.LocalDbInternal contains helpers to create, drop and detach databases, and to map file paths used for created databases.Obtain a context for tests:
// Simple: get an IDapperContext backed by LocalDB
using var context = MockedSqlDapperContext.GetInstance();
// Get instance with a logger
var ctx = MockedSqlDapperContext.GetInstance(myLogger);
// Get instance using a specific file path
var ctx2 = MockedSqlDapperContext.GetInstance(myLogger, "C:\\temp\\testdb.mdf");
Control reuse and lifecycle:
// When true, the same .mdf file may be reused across calls to speed up tests
MockedSqlDapperContext.ReuseDb = true;
// When false, each call will dispose any reused context and create a fresh database
MockedSqlDapperContext.ReuseDb = false;
// When false, a non-master database file will be used per GetInstance() call
MockedSqlDapperContext.UseMaster = false;
Register context creation for code that consumes the DapperContextFactory:
// Register the context creator so code calling DapperContextFactory.Instance.CreateContext() gets a mocked context
MockedSqlDapperContext.Use();
// Register once (adds a disposal handler)
MockedSqlDapperContext.UseOnce();
Docker support (modern runtimes only):
// On .NET 6+ you can opt into using Testcontainers if LocalDB is not available
MockedSqlDapperContext.UseDapperContext.UseDocker = true;
var ctx = MockedSqlDapperContext.GetInstance();
NET6_0_OR_GREATER.ReuseDb is disabled, the helper will attempt to clean up created .mdf and .ldf files when appropriate.UseMaster to control whether created databases are attached to the LocalDB master or created as separate files.UseDocker on supported runtimes to provision a SQL Server container instead..mdf files.DbContexts/MockedSqlDapperContext.* � the high-level context wrappers used by tests.Internals/SqlServer/LocalDbEnsurerInternal.cs and LocalDbInternal.cs � LocalDB provisioning, creation, attach/detach and helper functions.Internals/MockedSqlUseDapperContext.cs � the glue between high-level APIs and the LocalDB/Docker provisioning logic.This README summarizes usage and integration points. Inspect the source code and XML docs for detailed implementation and further customization.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net6.0 net6.0 is compatible. net6.0-android net6.0-android was computed. net6.0-ios net6.0-ios was computed. net6.0-maccatalyst net6.0-maccatalyst was computed. net6.0-macos net6.0-macos was computed. net6.0-tvos net6.0-tvos was computed. net6.0-windows net6.0-windows was computed. net7.0 net7.0 was computed. net7.0-android net7.0-android was computed. net7.0-ios net7.0-ios was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-macos net7.0-macos was computed. net7.0-tvos net7.0-tvos was computed. net7.0-windows net7.0-windows was computed. net8.0 net8.0 is compatible. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 is compatible. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
| .NET Framework | net40 net40 is compatible. net403 net403 was computed. net45 net45 is compatible. net451 net451 was computed. net452 net452 was computed. net46 net46 was computed. net461 net461 is compatible. net462 net462 was computed. net463 net463 was computed. net47 net47 was computed. net471 net471 was computed. net472 net472 was computed. net48 net48 was computed. net481 net481 was computed. |
Showing the top 1 NuGet packages that depend on Net4x.DapperLibrary.MockSqlServer:
| Package | Downloads |
|---|---|
|
Net4x.Xsd2Db.Base
Package Description |
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.9.9.8 | 138 | 2/2/2026 |
| 1.9.9.7 | 136 | 1/13/2026 |
| 1.9.9.6 | 135 | 1/6/2026 |
| 1.9.9.5 | 142 | 1/6/2026 |
| 1.9.9.4 | 135 | 1/6/2026 |
| 1.9.9.3 | 139 | 1/5/2026 |
| 1.9.9.2 | 149 | 12/30/2025 |
| 1.9.9.1 | 132 | 12/30/2025 |
| 1.9.9 | 227 | 12/22/2025 |
| 1.6.0.12 | 189 | 12/12/2025 |
| 1.6.0.11 | 182 | 12/12/2025 |
| 1.6.0.10 | 490 | 12/9/2025 |
| 1.6.0.9 | 269 | 12/4/2025 |
| 1.6.0.8 | 250 | 12/4/2025 |
| 1.6.0.7 | 314 | 11/30/2025 |
| 1.6.0.6 | 241 | 11/27/2025 |
| 1.6.0.5 | 312 | 11/22/2025 |
| 1.6.0.4 | 203 | 11/16/2025 |
| 1.6.0.3 | 230 | 11/15/2025 |
| 1.6.0.2 | 327 | 11/14/2025 |