Naravel.Database.EntityFrameworkCore 0.2.0

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

Naravel.Database.EntityFrameworkCore

NuGet Downloads .NET 10 License: MIT

EF Core interop for Naravel.Database: a DbContext and the query builder share one connection and one transaction.

Fact Detail
Install dotnet add package Naravel.Database.EntityFrameworkCore
Targets .NET 10
Needs Naravel.Database and Microsoft.EntityFrameworkCore.Relational, which NuGet installs with it, and the EF Core provider that your own DbContext uses
Providers SQLite, SQL Server, PostgreSQL (Npgsql) and MySQL

What you get

  • A builder query on the context. dbContext.Query("table") starts a query on the context's own connection and its current transaction.
  • One unit of work. An EF SaveChangesAsync and a builder write commit or roll back together, in the transaction you begin on the context.
  • Atomic statements beside tracked entities. Entities and change tracking stay in EF Core, while a guarded DecrementAsync or a bulk statement runs in the builder.
  • Listeners and the query log still see it. naravelDatabase.Using(dbContext) returns an IDatabase on the context's connection and transaction.

Quick start

using Microsoft.EntityFrameworkCore;
using Naravel.Database.EntityFrameworkCore;   // adds dbContext.Query("table") and database.Using(dbContext)

// db is your own DbContext, "Accounts" is the table that EF maps for your Accounts DbSet, and fromId, toId and amount are yours
await using var transaction = await db.Database.BeginTransactionAsync(ct);   // EF Core owns the transaction: begin it before the first builder call

var debited = await db.Query("Accounts")
    .Where("Id", fromId)
    .Where("Balance", ">=", amount)
    .DecrementAsync("Balance", amount, cancellationToken: ct);               // one guarded, atomic UPDATE on the context's connection
if (debited == 0)
    throw new InvalidOperationException("Unknown account or insufficient funds.");   // no commit: disposing the transaction rolls back

await db.Query("Accounts").Where("Id", toId).IncrementAsync("Balance", amount, cancellationToken: ct);
await db.SaveChangesAsync(ct);                                               // EF Core changes are saved in the same transaction
await transaction.CommitAsync(ct);

For dbContext.Query(...) only EF Core needs registering. The query builder only joins the transaction that is current when each command runs, so begin and finish it on the context; it never commits or rolls back one it did not start. The builder bypasses EF change tracking: an entity you already loaded does not see a builder update until you reload it or read it with AsNoTracking(). Use the table and column names that EF maps. For naravelDatabase.Using(dbContext), register AddNaravelDatabase as usual.

Package Adds
Naravel.Database The query builder, named connections and raw SQL

Learn more

Part of Naravel: Laravel's names, .NET's type system. All Naravel packages share one version.

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.2.0 96 11/13/2026
0.1.1 101 11/2/2026
0.1.0 109 11/1/2026