SurrealDB can be run as an embedded database within your .NET application, allowing you to use SurrealDB without running a separate server process. This is ideal for desktop applications, testing, local development, and edge computing scenarios.
Embedded database options
SurrealDB supports multiple types of embedded storage in .NET:
In-memory database (
mem://orSurrealDbMemoryClient) - Fastest performance with data stored in RAM. Perfect for testing, caching, or temporary data. Data is lost when the connection closes.File-based database (
rocksdb://,surrealkv://,SurrealDbRocksDbClient, orSurrealDbKvClient) - Persistent storage on disk using RocksDB or SurrealKV storage engines. Data persists across connections and application restarts.
Quick example
using SurrealDb.Net;
// In-memory database
using var db = new SurrealDbMemoryClient();
await db.Use("main", "main");
var person = await db.Create("person", new Person { Name = "John Doe" });
Console.WriteLine(person);
// File-based persistent database (RocksDB)
using var db = new SurrealDbRocksDbClient("mydb");
await db.Use("main", "main");
var company = await db.Create("company", new Company { Name = "TechStart" });
Console.WriteLine(company);For complete documentation, installation instructions, examples, best practices, and troubleshooting, see the .NET SDK embedding guide.