LiteDB

LiteDB - A .NET NoSQL Document Store in a single data file

What is LiteDB?

LiteDB - A .NET NoSQL Document Store in a single data file

Overview of LiteDB

What it is

LiteDB is a small, fast, and lightweight .NET NoSQL embedded database. It is a serverless document store that stores data in a single data file, similar to SQLite. It is written in 100% C# code for .NET 4.5 / NETStandard 1.3/2.0 in a single DLL (less than 450kb). It is thread-safe and supports ACID with full transaction support. Data recovery after write failure is provided via a WAL log file. The project is open source and free for everyone, including commercial use.

Key features

  • Serverless NoSQL Document Store with a simple API similar to MongoDB - Thread-safe with ACID and full transaction support - Data recovery after write failure (WAL log file)
  • Map POCO classes to BsonDocument using attributes or fluent mapper API - Store files and stream data (like GridFS in MongoDB)
  • Single data file storage (like SQLite)
  • Index document fields for fast search, LINQ support for queries, and SQL-Like commands - LiteDB Studio provides a UI for data access

Use cases

LiteDB is suitable for applications that need an embedded, serverless database with NoSQL document storage. It can be used in desktop applications, mobile apps, small web applications, or any .NET project where a lightweight, file-based database is preferred over a full database server. It is also useful for prototyping and for scenarios requiring ACID transactions without the overhead of a separate database process.

Getting started

Install from NuGet: Install-Package LiteDB A quick example for storing and searching documents: C# // Create your POCO class public class Customer { public int Id { get; set; } public string Name { get; set; } public int Age { get; set; } public string[] Phones { get; set; } public bool IsActive { get; set; } } // Open database (or create if doesn't exist) using(var db = new LiteDatabase(@”MyData.db”)) { // Get customer collection var col = db.GetCollection(“customers”); // Create your new customer instance var customer = new Customer { Name = “John Doe”, Phones = new string[] { “8000-0000”, “9000-0000” }, Age = 39, IsActive = true }; // Create unique index in Name field col.EnsureIndex(x => x.Name, true); // Insert new customer document (Id will be auto-incremented) col.Insert(customer); // Update a document inside a collection customer.Name = “Joana Doe”; col.Update(customer); // Use LINQ to query documents (with no index) var results = col.Find(x => x.Age > 20); }

License and pricing

The license is MIT. The project is open source and free for everyone, including commercial use. Pricing is not stated beyond being open source.

Based on the project's public README and repository metadata.

Add this badge to your README

Featured on YunoDB Badge styles & help

Maintain this project? Show that it is featured on YunoDB.

Markdown[![Featured on YunoDB](https://yunodb.com/badge/litedb-orglitedb.svg)](https://yunodb.com/tools/litedb-orglitedb?utm_source=github&utm_medium=badge)
HTML<a href="https://yunodb.com/tools/litedb-orglitedb?utm_source=github&utm_medium=badge"><img src="https://yunodb.com/badge/litedb-orglitedb.svg" alt="Featured on YunoDB" height="20"></a>