-
Notifications
You must be signed in to change notification settings - Fork 0
State Persistence
Aryeh Citron edited this page May 12, 2026
·
2 revisions
var db = result.Database as InMemoryMongoDatabase;
string json = db!.ExportState();
// json contains: {"collections":{"orders":[{...}, {...}], "customers":[{...}]}}var db = result.Database as InMemoryMongoDatabase;
db!.ImportState(json);
// Replaces all documents in all collections// Save snapshot to disk
db.ExportStateToFile("test-snapshot.json");
// Restore from disk
db.ImportStateFromFile("test-snapshot.json");Note: Import is a full replacement — existing documents are cleared before importing.
Note: Change streams and change logs are not persisted across Export/Import cycles.
- Seeding Data — Populating test data
- Setup Guide — DI configuration options
Getting Started
Integration & Dependency Injection
Data Management
Reference
- Feature Comparison
- Features
- Filter & Update Operators
- Aggregation Pipeline
- LINQ Support
- API Reference
Help