litedb-org /LiteDB
LiteDB - A .NET NoSQL Document Store in a single data file
★ 9,492⑂ 1,323👁 279⑃ 617● 2,446▤ 63
+0
Daily
9,492
stars
1,323
forks
279
watchers
617
prs
2,446
issues
63
releases
README
LiteDB - A .NET NoSQL Document Store in a single data file
LiteDB is a small, fast and lightweight .NET NoSQL embedded database.
- Serverless NoSQL Document Store
- Simple API, similar to MongoDB
- 100% C code for .NET 4.5 / NETStandard 1.3/2.0 in a single DLL (less than 450kb)
- Thread-safe
- ACID with full transaction support
- Data recovery after write failure (WAL log file)
- ~~Datafile encryption using DES (AES) cryptography~~ This implemention is currently not secure, DO NOT USE.
- Map your 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
- SQL-Like commands to access/transform data
- LiteDB Studio - Nice UI for data access
- Open source and free for everyone - including commercial use
- Install from NuGet: Install-Package LiteDB
New v5
- New storage engine
- No locks for read operations (multiple readers)
- Write locks per collection (multiple writers)
- Internal/System collections
- New SQL-Like Syntax
- New query engine (support projection, sort, filter, query)
- Partial document load (root level)
- and much, much more!
Lite.Studio
New UI to manage and visualize your database:
!LiteDB.Studio
Documentation
Visit the Wiki for full documentation. For simplified chinese version, check here.
LiteDB Community
Help LiteDB grow its user community by answering this simple survey
How to use 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);
}
BSON serialization
If you need direct access to raw BSON, BsonSerializer exposes overloads that write into caller-supplied Memory or IBufferWriter instances. This allows applications to reuse buffers from pools without forcing an intermediate array allocation. The Memory must be backed by a managed array. The IBufferWriter overload is available in the net8.0 and net10.0 builds, but is omitted from the netsTop issues
#2623v6.0.0 release readiness14 comments · 2025-09-20#1198Do you have plan to support for EntityFramework14 comments · 2019-03-24#2450[BUG] Rebuild function never deletes the previous database backup11 comments · 2024-03-17#1881[SUGGESTION] Documentation for transactions in v59 comments · 2020-11-24#2832Feature roadmap: Source generation, AOT/trimming, package size and serialization speed (generated mappers, AOT annotations, expression interpreter)8 comments · 2026-09-12#2043[BUG] Cannot insert duplicate key in unique index '_id'8 comments · 2021-07-29#1467DB/Collection breaks after power loss?8 comments · 2020-02-11#3074CI: full matrix is failing on dev7 comments · 2026-09-30
Discussions
#3148LiteDB.Identity ASP.NET Core Identity stores for LiteDB (.NET 11, 10 and 9)0 comments · 2026-11-15#2744Here is an extension for VSCode0 comments · 2026-03-16#2734Is there a way to use a change data capture (CDC)?0 comments · 2026-01-05#2731test1 comments · 2025-11-29#2720Index Helper Question0 comments · 2025-10-28#2640v6.0.0-prerelease.00150 comments · 2025-09-23#2622Embedded custom type deserializes to BsonValue, not the the custom type0 comments · 2025-09-15#2604Is LiteDB no longer being updated?1 comments · 2025-04-30
Latest release
v5.0.21 v5.0.21 2024-07-05What's Changed Fix 2265 Stackoverflow when Self reference by @JKamsker in https://github.com/mbdavid/LiteDB/pull/2493 Add-Badges by @JKamsker in https://github.com/mbdavid/LiteDB/pull/2496 Fix crash with stack trace by @Pysis868 in https://github.com/mbdavid/LiteDB/pull/2476 Fix LiteFileStream.SetReadStreamPosition by @SpaceCheetah in https://github.com/mbdavid/LiteDB/pull/2459 Addresses issue of upgrading from v4.x databases in LiteDB versions 5.0.18-5.0.20 by @jdtkw in https://github.com/mbdavid/LiteDB/pull/2499 Don't capture synchronization context in DiskWriterQueue by @alexber