LeanDb.EntityFrameworkCore 0.1.3

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

LeanDb.EntityFrameworkCore

Entity Framework Core query implementation for LeanDb. Use this package to execute LeanDb queries against any database via EF Core DbContext.

Usage

// Define a query
public record GetUserCount : IQuery<int>;

// Define its EF Core implementation
public class GetUserCountImplementation : IEfCoreQueryImplementation<AppDbContext, int>
{
    public GetUserCountImplementation(GetUserCount _) { }

    public async Task<int> Execute(AppDbContext dbContext, CancellationToken cancellationToken)
        => await dbContext.Users.CountAsync(cancellationToken);
}

// Register with DI
services.AddDbContext<AppDbContext>(options =>
    options.UseSqlServer(connectionString));

services.AddEfCoreDb<AppDbContext>(options =>
    options.LoadImplementationsFromAssembly(typeof(GetUserCountImplementation)));

// Execute
var db = serviceProvider.GetRequiredService<EfCoreDb<AppDbContext>>();
var count = await db.Execute(new GetUserCount());

How it works

  1. Define a query — create a record or class implementing IQuery<TResult>.
  2. Implement the query — create a class implementing IEfCoreQueryImplementation<TDbContext, TResult>. The implementation receives the typed TDbContext and executes the query using EF Core methods.
  3. Register — call AddEfCoreDb<TDbContext>() on your IServiceCollection, pointing to the assembly that contains your implementations.
  4. Execute — resolve EfCoreDb<TDbContext> and call Execute(query).

Registration

services.AddEfCoreDb<TDbContext>(options =>
{
    // Required: scan an assembly for query implementations
    options.LoadImplementationsFromAssembly(typeof(SomeImplementation));

    // Optional: scan additional assemblies
    options.LoadImplementationsFromAssembly(typeof(OtherImplementation));
});

The EfCoreDb<TDbContext> is registered as scoped, matching the typical lifetime of an EF Core DbContext.

Requirements

  • .NET 10 or later
  • Microsoft.EntityFrameworkCore.SqlServer (or your EF Core provider of choice)
  • LeanDb and LeanDb.ImplementationAbstractions
Package Description
LeanDb Core abstractions — define queries in your domain layer
LeanDb.ImplementationAbstractions Helper base types for building custom implementations
LeanDb.Dapper Alternative Dapper-based query implementation
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.1.3 93 8/29/2026
0.1.1 101 8/24/2026
0.0.2 113 8/2/2026
0.0.1 107 8/2/2026