CoreEx.EntityFrameworkCore 4.0.0-preview-1

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

CoreEx.EntityFrameworkCore

Provides the Entity Framework Core integration layer: EfDb<TDbContext> as the CoreEx-EF bridge, EfDbModel<TModel> and EfDbMappedModel<TValue, TModel, TMapper> for typed CRUD + query operations, EfDbExtensions for paged IQueryable<T> mapping helpers, EfDbInvoker for OpenTelemetry tracing, and EF ValueConverter bridges for CoreEx converter types.

Overview

CoreEx.EntityFrameworkCore wraps EF Core's DbContext with the CoreEx data conventions: IUnitOfWork transaction management, ETag/concurrency-token checking, multi-tenancy filtering, logical-delete filtering, change-log stamping, PagingArgs paging, QueryArgsConfig dynamic filter/orderby, and Result<T> pipeline integration.

The central type is EfDb<TDbContext>, which holds the DbContext, bridges its IDatabase (for transaction sharing with raw SQL), and exposes Model<TModel>() as the entry point for all strongly-typed CRUD. EfDbModel<TModel> provides GetAsync, CreateAsync, UpdateAsync, DeleteAsync, and Query — each applying the full CoreEx cross-cutting pipeline. EfDbMappedModel<TValue, TModel, TMapper> adds a IBiDirectionMapper layer for use cases where the EF model type differs from the domain entity type.

EfDbExtensions provides IQueryable<T> extension methods for mapping, paging, and ItemsResult<T> collection building, enabling consistent paged-list patterns across all EF-backed repositories without boilerplate.

Key capabilities

  • 🔗 EF + IDatabase bridge: EfDb<TDbContext> synchronizes EF Core's transaction with the underlying IDatabase.CurrentTransaction, so raw SQL commands and EF operations participate in the same ADO.NET transaction.
  • 📖 Typed CRUD: EfDbModel<TModel> provides GetAsync, CreateAsync, UpdateAsync, DeleteAsync with automatic ETag/concurrency-token validation, tenant isolation, logical-delete filtering, and change-log stamping.
  • 🔁 Mapped CRUD: EfDbMappedModel<TValue, TModel, TMapper> layers a IBiDirectionMapper<TValue, TModel> over EfDbModel<TModel>, mapping between the domain entity type and the EF model type transparently for all CRUD operations.
  • 🔍 Query with dynamic filter/orderby: EfDbModel<TModel>.Query(args?) returns a fluent EfDbQuery<TModel> that applies QueryArgsConfig filter and orderby, tenant and logical-delete predicates, and paging.
  • 📄 Paged IQueryable extensions: EfDbExtensions.ToMappedItemsResultAsync, ToItemsResultAsync, ToMappedCollectionAsync convert an IQueryable<TSource> to paged ItemsResult<T> or collections with a mapper function or IMapper<T>.
  • 🏷️ ETag / concurrency token: EfDbArgs.CheckETag compares the incoming ETag against the current entity's concurrency token before update/delete, throwing ConcurrencyException on mismatch.
  • 🔒 Multi-tenancy filtering: EfDbModel automatically adds TenantId == executionContext.TenantId predicates for entities implementing IReadOnlyTenantId.
  • 🗑️ Logical delete: Entities implementing IReadOnlyLogicallyDeleted are soft-deleted (IsDeleted = true) on DeleteAsync rather than physically removed, and filtered out of GetAsync / Query.
  • 🔌 ValueConverter bridge: ValueConverterBridge<TModel, TProvider> and JsonElementStringEfConverter allow CoreEx IConverter<T, U> implementations to be used directly as EF Core ValueConverter instances in OnModelCreating.
  • 📡 OpenTelemetry: EfDbInvoker wraps every EfDb operation with an Activity span tagged with operation type, model type, and result.

Key types

Type Description
EfDb<TDbContext> CoreEx EF bridge: holds DbContext, IDatabase, EfDbOptions, ExecutionContext; exposes Model<TModel>() entry point; synchronizes EF and ADO.NET transactions.
EfDbModel<TModel> Strongly-typed CRUD + query for a single EF model type: GetAsync, CreateAsync, UpdateAsync, DeleteAsync, Query(args?); applies full CoreEx cross-cutting pipeline.
EfDbMappedModel<TValue, TModel, TMapper> Adds a IBiDirectionMapper<TValue, TModel> layer over EfDbModel<TModel> for domain entity ↔ EF model type conversion; provides GetAsync, CreateAsync, UpdateAsync, DeleteAsync.
EfDbExtensions IQueryable<T> extensions: ToMappedItemsResultAsync, ToItemsResultAsync, ToMappedCollectionAsync, BuildQuery(QueryArgs, QueryArgsConfig).
EfDbArgs Per-operation options: OperationType, CheckETag, Paging, ExceptionHandler; defaults sourced from EfDbModelOptions<TModel> then EfDbOptions.
EfDbOptions Instance-level options for EfDb<TDbContext>: default EfDbArgs, per-model options registry via GetOrAddModelOptions<TModel>().
EfDbModelOptions<TModel> Per-model configuration: optional EfDbArgs override, OnQuery hook, tenant/logical-delete filtering enable/disable.
EfDbInvoker InvokerBase<IEfDb> emitting OpenTelemetry spans and structured log entries for every EfDb operation; Default singleton used by EfDb<TDbContext>.
ValueConverterBridge<TModel, TProvider> EF Core ValueConverter<TModel, TProvider> that delegates to a CoreEx IConverter<TModel, TProvider>, bridging CoreEx converter types into EF model configuration.
JsonElementStringEfConverter EF Core ValueConverter serializing JsonElement values to/from string for storing JSON fragments in a text column.
IEfDb Interface exposing DbContext, IDatabase, EfDbOptions, ExecutionContext, and EfDbInvoker; implemented by EfDb<TDbContext>.
IEfDbContext Marker interface for DbContext subclasses wiring the IDatabase bridge via BaseDatabase.

Namespaces

Namespace Description
Converters ValueConverterBridge<TModel, TProvider> and JsonElementStringEfConverter for use in EF Core model configuration.
  • CoreEx.Data - IUnitOfWork, DataResult, QueryArgsConfig; EF unit-of-work is typically composed using EfDb with an outbox publisher.
  • CoreEx.Database - IDatabase is bridged into EfDb<TDbContext> for transaction sharing and raw SQL fallback; IDatabaseUnitOfWork can wrap EfDb.
  • CoreEx.Mapping - IBiDirectionMapper<TValue, TModel> is the mapper contract used by EfDbMappedModel; Mapper.MapStandardFrom handles standard entity-contract properties.
  • CoreEx.Invokers - EfDbInvoker extends InvokerBase<IEfDb> using the standard OpenTelemetry tracing and logging pipeline.

AI Usage Guide

An AGENTS.md file is included with this package. AI coding assistants (GitHub Copilot, Claude, Cursor, etc.) that support workspace-injected package documentation will automatically surface concise usage guidance, code examples, and Do Not rules for this package without requiring a local CoreEx checkout.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  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 (1)

Showing the top 1 popular GitHub repositories that depend on CoreEx.EntityFrameworkCore:

Repository Stars
Avanade/Beef
The Business Entity Execution Framework (Beef) framework, and the underlying code generation, has been primarily created to support the industrialization of API development.
Version Downloads Last Updated
4.0.0-preview-1 49 6/20/2026
3.31.0 4,108 2/1/2025
3.30.2 249 12/11/2024
3.30.1 264 12/9/2024
3.30.0 1,402 11/21/2024
3.29.0 272 11/19/2024
3.28.0 256 11/9/2024
3.27.3 516 10/23/2024
3.27.2 275 10/17/2024
3.27.1 311 10/15/2024
3.27.0 283 10/11/2024
3.26.0 275 10/3/2024
3.25.6 334 10/2/2024
3.25.5 290 9/25/2024
3.25.4 269 9/24/2024
3.25.3 283 9/18/2024
3.25.2 289 9/17/2024
3.25.1 328 9/16/2024
3.25.0 264 9/10/2024
3.24.1 327 8/7/2024
Loading failed