SoftwareDriven.Persistence.EF.SQLite 3.1.0

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

SoftwareDriven.Persistence.EF.SQLite

Entity Framework Core / SQLite provider for SoftwareDriven.Persistence. Bundles the EF Core base provider. Targets net10.0.

Installation

dotnet add package SoftwareDriven.Persistence.EF.SQLite

Setup

// Register EF manager and providers
services.AddEntityFramework<SQLiteManager>();
services.AddEFProviderScoped<MyModel>((modelBuilder, entityBuilder) =>
{
    entityBuilder.HasMany(x => x.Children).WithOne().OnDelete(DeleteBehavior.Cascade);
});

// Connect
var manager = serviceProvider.GetRequiredService<EFManager>() as SQLiteManager;
await manager!.Connect("data/mydb.db");

With DbContext options

await manager.Connect("data/mydb.db", options =>
{
    options.EnableSensitiveDataLogging();
});

Provider Registration

// Scoped (recommended for web apps)
services.AddEFProviderScoped<MyModel>(map, registerBaseInterface: true);

// Singleton
services.AddEFProviderSingleton<MyModel>(map, registerBaseInterface: true);

// Without mapping
services.AddEFProviderScoped<SimpleModel>();

The registerBaseInterface parameter controls whether IBasicPersistenceProvider<T> is registered in DI (default: true). Set to false when resolving the concrete EFRepositoryProvider<T> directly.

Entity Mapping

services.AddEFProviderScoped<Order>((modelBuilder, entityBuilder) =>
{
    // Complex types
    modelBuilder.Entity<Address>().ComplexProperty(x => x.Location);

    // Relationships
    entityBuilder.HasMany(x => x.Items).WithOne().OnDelete(DeleteBehavior.Cascade);
});

Usage

var provider = serviceProvider.GetRequiredService<EFRepositoryProvider<MyModel>>();

await provider.CreateOrUpdate(new MyModel { Title = "Hello" });
var results = await provider.FindByExpression(x => x.Title == "Hello");

Maintenance

var statistics = await manager.GetStatistics();
// TotalBytes:       database file plus write-ahead log
// ReclaimableBytes: freelist_count * page_size, i.e. the pages deleting released for reuse only

var result = await manager.Compact();
// BytesBefore / BytesAfter tell what the compaction achieved

Compact() runs VACUUM followed by PRAGMA wal_checkpoint(TRUNCATE). The checkpoint is not optional: in WAL mode VACUUM writes the compacted pages into the write-ahead log and the database file keeps its size until a checkpoint runs.

Note:

  • VACUUM rewrites the whole database and therefore needs the double amount of storage while it runs.
  • It needs exclusive access; other connections with running statements let it fail.
  • Microsoft.Data.Sqlite has no asynchronous path, so Compact() runs synchronously on the calling thread despite its Task based signature. Move it off the UI thread yourself if the database is large.

Features

  • SupportsTotalCount: true
  • SupportsPagingState: false (offset-based pagination)
  • DefaultIdSource: GuidSource
  • SupportsMaintenance: true (VACUUM plus WAL checkpoint)
  • Implements IBasicPersistenceProvider<T> (not the extended IPersistenceProvider<T>)

License

MIT

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
3.1.0 38 8/25/2026
3.0.4 147 4/2/2026
3.0.3 140 2/11/2026
3.0.0 144 2/1/2026
2.12.0 146 1/8/2026
2.9.0 297 11/30/2024
2.8.0 258 7/7/2024
2.7.12 253 6/10/2024
2.7.11 231 6/4/2024
2.7.10 205 6/3/2024
2.7.9 224 6/3/2024
2.7.8 252 5/29/2024
2.7.7 255 5/24/2024
2.7.6 256 5/16/2024
2.7.5 232 5/16/2024
2.7.4 261 5/7/2024
2.7.2 268 5/7/2024
2.7.1 270 4/22/2024
2.7.0 308 11/27/2023