InMemoryEmulator.MongoDB
1.1.4
dotnet add package InMemoryEmulator.MongoDB --version 1.1.4
NuGet\Install-Package InMemoryEmulator.MongoDB -Version 1.1.4
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="InMemoryEmulator.MongoDB" Version="1.1.4" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="InMemoryEmulator.MongoDB" Version="1.1.4" />
<PackageReference Include="InMemoryEmulator.MongoDB" />
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 InMemoryEmulator.MongoDB --version 1.1.4
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: InMemoryEmulator.MongoDB, 1.1.4"
#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 InMemoryEmulator.MongoDB@1.1.4
#: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=InMemoryEmulator.MongoDB&version=1.1.4
#tool nuget:?package=InMemoryEmulator.MongoDB&version=1.1.4
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
<img src="icon.svg" width="32" height="32" alt="InMemoryEmulator.MongoDB icon" style="vertical-align: middle;"> InMemoryEmulator.MongoDB
A high-fidelity, in-process fake for the MongoDB .NET/C# Driver — zero Docker, zero network, instant startup.
Why?
- Instant — ~0ms startup (vs 2-15s for Docker/Mongo2Go)
- Portable — No Docker, no
mongodbinaries, no ports - Reliable — No flaky timeouts, port conflicts, or container failures
- High-fidelity — Real filter, update, and aggregation semantics (not mocks)
Quick Start
dotnet add package InMemoryEmulator.MongoDB # for MongoDB.Driver 3.x
dotnet add package InMemoryEmulator.MongoDB.V2Driver # for MongoDB.Driver 2.x
Unit Tests
var result = InMemoryMongo.Create<Order>("orders");
var collection = result.Collection;
await collection.InsertOneAsync(new Order { Total = 99.99m });
var found = await collection.Find(o => o.Total > 50).FirstOrDefaultAsync();
Integration Tests (DI)
services.UseInMemoryMongoDB(options =>
{
options.DatabaseName = "testdb";
options.AddCollection<Order>("orders");
});
What's Supported
| Feature | Status |
|---|---|
| Full CRUD (Insert, Find, Update, Replace, Delete, BulkWrite) | ✅ |
| Aggregation Pipeline (34 stages, 100+ expression operators) | ✅ |
| Indexes (Unique, Compound, Sparse, Partial Filter, TTL) | ✅ |
| Change Streams | ✅ |
| Transactions (snapshot isolation) | ✅ |
| GridFS | ✅ |
Schema Validation ($jsonSchema) |
✅ |
| Capped Collections + Tailable Cursors | ✅ |
| Views | ✅ |
LINQ (AsQueryable()) |
✅ |
| Fault Injection | ✅ |
| State Persistence (Export/Import) | ✅ |
| DI Integration (2 extension methods) | ✅ |
NuGet Packages
Both packages share the same namespace (
InMemoryEmulator.MongoDB) and feature set. Pick the one matching your driver version — the API is identical.
Documentation
See the Wiki for full documentation:
- Getting Started
- Setup Guide (5 DI patterns)
- Features
- Filter & Update Operators
- Aggregation Pipeline (34 stages)
- Migration Guide (from Mongo2Go / Testcontainers)
- Known Limitations
Requirements
- .NET 8.0+
InMemoryEmulator.MongoDBrequires MongoDB.Driver 3.x (tested up to 3.8.1)InMemoryEmulator.MongoDB.V2Driverrequires MongoDB.Driver 2.x (tested up to 2.30.0)
License
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. 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.
-
net8.0
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.2)
- MongoDB.Driver (>= 3.8.1)
- NetTopologySuite (>= 2.5.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on InMemoryEmulator.MongoDB:
| Package | Downloads |
|---|---|
|
InMemoryEmulator.MongoDB.JsTriggers
JavaScript expression support for InMemoryEmulator.MongoDB. Uses Jint to execute $function, $accumulator, and $where expressions inside your in-memory tests. |
GitHub repositories
This package is not used by any popular GitHub repositories.