Bounteous.Data.SQLite 0.0.2

dotnet add package Bounteous.Data.SQLite --version 0.0.2
                    
NuGet\Install-Package Bounteous.Data.SQLite -Version 0.0.2
                    
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="Bounteous.Data.SQLite" Version="0.0.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Bounteous.Data.SQLite" Version="0.0.2" />
                    
Directory.Packages.props
<PackageReference Include="Bounteous.Data.SQLite" />
                    
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 Bounteous.Data.SQLite --version 0.0.2
                    
#r "nuget: Bounteous.Data.SQLite, 0.0.2"
                    
#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 Bounteous.Data.SQLite@0.0.2
                    
#: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=Bounteous.Data.SQLite&version=0.0.2
                    
Install as a Cake Addin
#tool nuget:?package=Bounteous.Data.SQLite&version=0.0.2
                    
Install as a Cake Tool

Bounteous.Data.SQLite

SQLite provider wrapper for Bounteous.Data. It supplies SqliteDbContextFactory<T, TUserId>, which configures EF Core's SQLite provider and inherits auditing, soft delete, and observer support from Bounteous.Data.

Sibling packages: Bounteous.Data.SqlServer, Bounteous.Data.PostgreSQL, Bounteous.Data.MySQL.

Installation

dotnet add package Bounteous.Data.SQLite

Usage

1. Define the context

public class AppDbContext(
    DbContextOptions options,
    IDbContextObserver observer,
    IIdentityProvider<Guid> identityProvider)
    : DbContextBase<Guid>(options, observer, identityProvider)
{
    public DbSet<Customer> Customers => Set<Customer>();

    protected override void RegisterModels(ModelBuilder modelBuilder)
        => modelBuilder.Entity<Customer>().HasKey(c => c.Id);
}

2. Derive the factory

using Bounteous.Data.SQLite;

public class AppDbContextFactory(
    IConnectionBuilder connectionBuilder,
    IDbContextObserver observer,
    IIdentityProvider<Guid> identityProvider)
    : SqliteDbContextFactory<AppDbContext, Guid>(connectionBuilder, observer, identityProvider)
{
    protected override AppDbContext Create(DbContextOptions options, IDbContextObserver observer,
        IIdentityProvider<Guid> identityProvider)
        => new(options, observer, identityProvider);
}

3. Use it

await using var context = factory.Create();
context.Customers.Add(new Customer { Id = Guid.NewGuid(), Name = "Acme" });
await context.SaveChangesAsync(); // CreatedBy/ModifiedBy/CreatedOn set by Bounteous.Data

What the factory configures

new DbContextOptionsBuilder<DbContextBase<TUserId>>()
    .UseSqlite(ConnectionBuilder.AdminConnectionString)
    .EnableSensitiveDataLogging(sensitiveDataLoggingEnabled)
    .EnableDetailedErrors()
    .Options;

There is no EnableRetryOnFailure(), unlike the SQL Server, PostgreSQL, and MySQL wrappers. SQLite runs in-process, so there are no transient network faults to retry, and the EF Core SQLite provider has no retrying execution strategy.

Connection strings

Scenario Connection string
File database Data Source=app.db
Read-only file Data Source=app.db;Mode=ReadOnly
Private in-memory Data Source=:memory:
Shared in-memory Data Source=mydb;Mode=Memory;Cache=Shared

In-memory databases

An in-memory SQLite database lives only while a connection to it is open. Each factory.Create() opens its own connection, so with Data Source=:memory: every context sees a new, empty database.

To share one in-memory database across contexts (typical for tests), use a named shared-cache database and hold one connection open for its lifetime:

const string cs = "Data Source=tests;Mode=Memory;Cache=Shared";
using var keepAlive = new SqliteConnection(cs);
keepAlive.Open();
// contexts created by a factory returning `cs` now share the same data

SQLite limits to know

  • No decimal ordering or aggregation on the server side; EF Core stores decimal as TEXT. Use double or convert on the client if you need ORDER BY / SUM.
  • DateTimeOffset is stored as TEXT; ordering and comparison are limited.
  • Schema changes are restricted (no ALTER COLUMN); EF Core migrations rebuild tables where needed.
  • One writer at a time. Fine for tests, local tools, and edge/desktop apps; not a substitute for a server database under concurrent write load.

Dependencies

  • Bounteous.Data 0.0.31
  • Microsoft.EntityFrameworkCore.Sqlite 10.0.14
  • SQLitePCLRaw.bundle_e_sqlite3 3.0.5 (pinned so the bundled native SQLite stays ahead of the version EF Core pulls transitively)

Dependabot keeps these current.

Build and test

dotnet build -c Release
dotnet test -c Release

Tests run against real SQLite in memory. No Docker or external database needed.

License

MIT. See LICENSE.

Product Compatible and additional computed target framework versions.
.NET 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
0.0.2 86 11/4/2026