SQLite.Framework.SourceGenerator
5.0.0-preview.1
See the version list below for details.
dotnet add package SQLite.Framework.SourceGenerator --version 5.0.0-preview.1
NuGet\Install-Package SQLite.Framework.SourceGenerator -Version 5.0.0-preview.1
<PackageReference Include="SQLite.Framework.SourceGenerator" Version="5.0.0-preview.1"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>
<PackageVersion Include="SQLite.Framework.SourceGenerator" Version="5.0.0-preview.1" />
<PackageReference Include="SQLite.Framework.SourceGenerator"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>
paket add SQLite.Framework.SourceGenerator --version 5.0.0-preview.1
#r "nuget: SQLite.Framework.SourceGenerator, 5.0.0-preview.1"
#:package SQLite.Framework.SourceGenerator@5.0.0-preview.1
#addin nuget:?package=SQLite.Framework.SourceGenerator&version=5.0.0-preview.1&prerelease
#tool nuget:?package=SQLite.Framework.SourceGenerator&version=5.0.0-preview.1&prerelease
SQLite.Framework
A lightweight ORM for SQLite, designed for .NET MAUI and Avalonia with AOT support and LINQ-style IQueryable querying.
Features
- AOT-ready: Designed for Ahead-Of-Time compilation in .NET MAUI and Avalonia apps.
- IQueryable interface: Write LINQ queries against your SQLite database.
- Inspired by EF & sqlite-net-pcl: Familiar patterns with minimal overhead.
Documentation
- GitHub Wiki - browse the docs on GitHub
- GitHub Pages - the same docs as a standalone site
Installation
Install via NuGet:
dotnet add package SQLite.Framework
Quick Start
Define your model:
public class Person { [Key, AutoIncrement] public int Id { get; set; } public required string Name { get; set; } public DateTime? BirthDate { get; set; } }Initialize the context:
using SQLite.Framework; var options = new SQLiteOptionsBuilder("app.db").Build(); using var context = new SQLiteDatabase(options); context.Table<Person>().CreateTable();On the table class, you can use the following:
- The [Table] attribute to specify the table name.
- The [WithoutRowId] attribute to use the without rowid optimization.
On the class properties:
- The [Column] attribute specifies the column name.
- The [NotMapped] attribute ignores the property.
- The [Key] attribute specifies the primary key.
- The [Index] attribute creates an index on the column or make a column unique.
- The [AutoIncrement] attribute is used to specify that the column should be auto-incremented.
- The [Required] attribute is used to specify that the column is NOT NULL (columns are NOT NULL by default, but using the ? operator marks them as nullable).
Query with LINQ:
// Insert context.Add(new Person { Name = "Alice" }); // Query var results = context.Table<Person>() .Where(p => p.Name.StartsWith("A")) .OrderBy(p => p.Id) .Select(p => new { p.Id + 1, p.Name }) .ToList();Async query with LINQ:
// Insert await context.AddAsync(new Person { Name = "Alice" }); // Query var results = await context.Table<Person>() .Select(p => p.Id) .ToListAsync();
AOT Support
For Native AOT builds, install SQLite.Framework.SourceGenerator and turn it on when you build your options:
dotnet add package SQLite.Framework.SourceGenerator
using SQLite.Framework.Generated;
var options = new SQLiteOptionsBuilder("app.db")
.UseGeneratedMaterializers()
.Build();
The generator writes the code that reads SQLite rows into your .NET objects at build time, so the trimmer can see every public type used in a Select and no reflection is needed for those. Private types and private methods that appear in a Select still go through a small amount of reflection.
UseGeneratedMaterializers is generated per project. The class and the extension method are marked internal, so if your solution has several projects that build LINQ queries, each one needs its own reference to SQLite.Framework.SourceGenerator and its own call to UseGeneratedMaterializers.
See the Source Generator and Native AOT pages for the full setup.
Without the generator, the library still runs under AOT but uses reflection for each query. In that case, make sure the classes you query are either part of the AOT-compiled assembly or referenced directly in your code so the trimmer keeps them.
Contributing
Feel free to:
- Report bugs or missing features.
- Submit PRs to add functionality or tests.
License
MIT © Nikolay Kostadinov
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.0
- No dependencies.
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 |
|---|---|---|
| 5.3.0 | 37 | 5/12/2026 |
| 5.2.0 | 57 | 5/9/2026 |
| 5.1.0 | 96 | 5/3/2026 |
| 5.0.3 | 94 | 5/1/2026 |
| 5.0.2 | 97 | 4/29/2026 |
| 5.0.1 | 95 | 4/29/2026 |
| 5.0.0 | 100 | 4/29/2026 |
| 5.0.0-preview.2 | 83 | 4/23/2026 |
| 5.0.0-preview.1 | 70 | 4/22/2026 |