SQLiteSharp 6.6.0
dotnet add package SQLiteSharp --version 6.6.0
NuGet\Install-Package SQLiteSharp -Version 6.6.0
<PackageReference Include="SQLiteSharp" Version="6.6.0" />
<PackageVersion Include="SQLiteSharp" Version="6.6.0" />
<PackageReference Include="SQLiteSharp" />
paket add SQLiteSharp --version 6.6.0
#r "nuget: SQLiteSharp, 6.6.0"
#:package SQLiteSharp@6.6.0
#addin nuget:?package=SQLiteSharp&version=6.6.0
#tool nuget:?package=SQLiteSharp&version=6.6.0
SQLiteSharp
SQLiteSharp is a powerful library to help you access a SQLite database in C#.
<img src="https://github.com/Joy-less/SQLiteSharp/blob/main/Assets/SQLette%20Face.png?raw=true" width=220>
SQLette protecting your database schema from getting corrupted.
Features
- Create tables from your .NET objects
- Annotate members as primary keys, foreign keys, not null, unique, indexed and more
- Manage your database with No-SQL APIs
- Use synchronous and asynchronous functions
- Encrypt your database with SQLCipher
Background
This project was originally based on SQLite-net by Krueger Systems Inc.
SQLiteSharp is a complete rewrite of the original, providing a modern experience akin to MongoDB or LiteDB with the power of SQLite.
Example
First, declare your object with optional annotations:
public class ShopItem {
[PrimaryKey, AutoIncrement]
public long Id { get; set; }
[NotNull]
public string? ItemName { get; set; }
public long Count { get; set; }
[Ignore]
public int SomethingToIgnore { get; set; }
}
Second, open a connection to your database:
// Open a database connection
using SqliteConnection Connection = new("database.db");
// Create a table for a class
SqliteTable<ShopItem> ShopItems = Connection.GetTable<ShopItem>();
// Delete all existing items in the table
ShopItems.DeleteAll();
// Insert items into the table
ShopItems.Insert(new ShopItem() {
ItemName = "Apple",
Count = 10,
});
ShopItems.Insert(new ShopItem() {
ItemName = "Banana",
Count = 5,
});
// Find one item in the table matching a predicate
ShopItem? Apple = ShopItems.FindOne(ShopItem => ShopItem.ItemName == "Apple");
// Delete an item from the table
ShopItems.DeleteByKey(Apple.Id);
// Find several items in the table
List<ShopItem> Bananas = ShopItems.Find(ShopItem => ShopItem.ItemName == "Banana").ToList();
Custom Type Serialization
SQLiteSharp supports serialization for a set of common types.
Polymorphism is supported, so you can register object as a fallback for all missing types.
By default, unregistered types are serialized as JSON using System.Text.Json.
public class SweetWrapper {
public Sweet? Sweet { get; set; } // custom type
}
public class Sweet(string Flavour) {
public string? Flavour { get; set; } = Flavour;
}
// Open a database connection
using SqliteConnection Connection = new(":memory:");
// Register custom type
Connection.Orm.RegisterType<Sweet>(
SqliteType.Text,
serialize: (Sweet Sweet) => JsonSerializer.Serialize(Sweet),
deserialize: (SqliteValue Value, Type ClrType) => (Sweet?)JsonSerializer.Deserialize(Value.CastText, ClrType)
);
Tips
Automatic Schema Migration
Tables are automatically migrated to add new tables and columns, however existing columns are not modified.
Thread Safety
A SqliteConnection should not be used by multiple threads. However, multiple SqliteConnections can be opened and used concurrently, since they use SQLite's built-in FullMutex.
Versioning Guide
SQLiteSharp uses versions like "1.0" and "2.4".
For developers:
- Increment the major version when adding new features or making breaking changes.
- Increment the minor version when fixing bugs or making small improvements.
For users:
- You usually want the latest major version, although it may require some changes to your project.
- You always want the latest minor version, and there should not be any issues upgrading.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 is compatible. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- SQLitePCLRaw.bundle_e_sqlite3 (>= 3.0.5)
- System.Linq.AsyncEnumerable (>= 10.0.11)
- System.Text.Json (>= 10.0.11)
-
.NETStandard 2.1
- SQLitePCLRaw.bundle_e_sqlite3 (>= 3.0.5)
- System.Linq.AsyncEnumerable (>= 10.0.11)
- System.Text.Json (>= 10.0.11)
-
net10.0
- SQLitePCLRaw.bundle_e_sqlite3 (>= 3.0.5)
-
net8.0
- SQLitePCLRaw.bundle_e_sqlite3 (>= 3.0.5)
- System.Linq.AsyncEnumerable (>= 10.0.11)
- System.Text.Json (>= 10.0.11)
-
net9.0
- SQLitePCLRaw.bundle_e_sqlite3 (>= 3.0.5)
- System.Linq.AsyncEnumerable (>= 10.0.11)
- System.Text.Json (>= 10.0.11)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 6.6.0 | 36 | 8/27/2026 |
| 6.5.0 | 170 | 6/6/2026 |
| 6.4.0 | 112 | 6/6/2026 |
| 6.3.0 | 125 | 4/20/2026 |
| 6.2.0 | 110 | 4/20/2026 |
| 6.1.0 | 153 | 2/3/2026 |
| 6.0.0 | 352 | 11/12/2025 |
| 5.3.0 | 202 | 7/29/2025 |
| 5.2.0 | 349 | 5/15/2025 |
| 5.1.0 | 250 | 5/1/2025 |
| 5.0.0 | 277 | 4/8/2025 |
| 4.0.0 | 257 | 3/18/2025 |
| 3.2.0 | 310 | 3/8/2025 |
| 3.1.0 | 214 | 2/16/2025 |
| 3.0.0 | 211 | 1/18/2025 |
| 2.0.0 | 186 | 1/10/2025 |
| 1.1.0 | 206 | 12/25/2024 |
| 1.0.0 | 195 | 12/10/2024 |