SQLite.Framework.SourceGenerator 5.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package SQLite.Framework.SourceGenerator --version 5.0.0
                    
NuGet\Install-Package SQLite.Framework.SourceGenerator -Version 5.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SQLite.Framework.SourceGenerator" Version="5.0.0">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SQLite.Framework.SourceGenerator" Version="5.0.0" />
                    
Directory.Packages.props
<PackageReference Include="SQLite.Framework.SourceGenerator">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add SQLite.Framework.SourceGenerator --version 5.0.0
                    
#r "nuget: SQLite.Framework.SourceGenerator, 5.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package SQLite.Framework.SourceGenerator@5.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=SQLite.Framework.SourceGenerator&version=5.0.0
                    
Install as a Cake Addin
#tool nuget:?package=SQLite.Framework.SourceGenerator&version=5.0.0
                    
Install as a Cake Tool

SQLite.Framework

A lightweight ORM for SQLite, designed for .NET MAUI and Avalonia with AOT support and LINQ-style IQueryable querying.

NuGet

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

Installation

Install via NuGet:

dotnet add package SQLite.Framework

Quick Start

  1. Define your model:

    public class Person
    {
        [Key, AutoIncrement]
        public int Id { get; set; }
        public required string Name { get; set; }
        public DateTime? BirthDate { get; set; }
    }
    
  2. Initialize the database:

    using SQLite.Framework;
    
    var options = new SQLiteOptionsBuilder("app.db").Build();
    using var database = new SQLiteDatabase(options);
    database.Table<Person>().Schema.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).
  3. Query with LINQ:

    // Insert
    context.Table<Person>().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();
    
  4. Async query with LINQ:

    // Insert
    await context.Table<Person>().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

There are no supported framework assets in this package.

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