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.
SurrealDB supports multiple types of embedded storage in .NET:
In-Memory Database (mem:// or SurrealDbMemoryClient) - 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, or SurrealDbKvClient) - Persistent storage on disk using RocksDB or SurrealKV storage engines. Data persists across connections and application restarts.
using SurrealDb.Net; // In-memory database using var db = new SurrealDbMemoryClient(); await db.Use("test", "test"); 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("test", "test"); 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.