CoreEx.EntityFrameworkCore 4.0.0-preview-4

This is a prerelease version of CoreEx.EntityFrameworkCore.
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package CoreEx.EntityFrameworkCore --version 4.0.0-preview-4
                    
NuGet\Install-Package CoreEx.EntityFrameworkCore -Version 4.0.0-preview-4
                    
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-4" />
                    
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-4" />
                    
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-4
                    
#r "nuget: CoreEx.EntityFrameworkCore, 4.0.0-preview-4"
                    
#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-4
                    
#: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-4&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=CoreEx.EntityFrameworkCore&version=4.0.0-preview-4&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 structured operation logging, 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 configured filters: EfDbModel<TModel>.Query(args?) / QueryTracked(args?) return a plain IQueryable<TModel> with any WithFilter/WithTenantFilter/WithLogicalDeleteFilter predicates from EfDbModelOptions applied; pair with CoreEx.Data's QueryArgsConfig and the EfDbExtensions paging helpers to build dynamic filter/orderby/paged queries.
  • 📄 Paged IQueryable extensions: EfDbExtensions.ToItemsResultAsync, ToMappedItemsResultAsync, ToMappedItemsAsync convert an IQueryable<TSource> to paged ItemsResult<T> or collections with a mapper function or IMapper<T>.
  • 🏷️ ETag / concurrency token: for a detached UpdateAsync, EfDbModel compares the incoming model's ETag against the freshly-fetched entity's concurrency token via ETag.TryCompare, returning a ConcurrencyError result on mismatch.
  • 🔒 Multi-tenancy: non-query operations (GetAsync/CreateAsync/UpdateAsync/DeleteAsync) automatically reject a mismatched IReadOnlyTenantId.TenantId as not-found; Query() only applies the equivalent TenantId == executionContext.TenantId predicate when EfDbModelOptions.WithTenantFilter() has been configured.
  • 🗑️ Logical delete: entities implementing IReadOnlyLogicallyDeleted are soft-deleted (IsDeleted = true) on DeleteAsync rather than physically removed; non-query operations automatically treat a logically-deleted row as not-found, while Query() only excludes them when EfDbModelOptions.WithLogicalDeleteFilter() has been configured.
  • 🔌 ValueConverter bridge: ValueConverterBridge<TModel, TProvider> and JsonElementStringEfConverter allow CoreEx IConverter<T, U> implementations to be used directly as EF Core ValueConverter instances in OnModelCreating.
  • 📝 Structured logging: EfDbInvoker wraps every EfDb operation with structured log entries (tracing/Activity spans are intentionally disabled via IsTracingDisabled).

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: QueryTracking, ClearChangeTrackerAfterGet, SaveChanges, BypassFilters (plus inherited Refresh/TransformException); defaults sourced from EfDbModelOptions<TModel>.Args then EfDb.Options.Args.
EfDbOptions Instance-level options for EfDb<TDbContext>: default EfDbArgs, per-model options registry via GetOrAddModelOptions<TModel>().
EfDbModelOptions<TModel> Per-model configuration: WithArgs, WithGetKey, WithFilter/WithTenantFilter/WithLogicalDeleteFilter, WithOnBeforeCreateOrUpdate, WithUpdateModelMapper.
EfDbInvoker InvokerBase<IEfDb> emitting structured log entries for every EfDb operation (tracing intentionally disabled); 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-5 79 8/23/2026
4.0.0-preview-4 76 8/21/2026
4.0.0-preview-3 180 8/4/2026
4.0.0-preview-2 124 7/10/2026
4.0.0-preview-1 265 6/20/2026
3.31.0 4,638 2/1/2025
3.30.2 266 12/11/2024
3.30.1 280 12/9/2024
3.30.0 1,457 11/21/2024
3.29.0 293 11/19/2024
3.28.0 271 11/9/2024
3.27.3 538 10/23/2024
3.27.2 292 10/17/2024
3.27.1 337 10/15/2024
3.27.0 306 10/11/2024
3.26.0 289 10/3/2024
3.25.6 364 10/2/2024
3.25.5 306 9/25/2024
3.25.4 292 9/24/2024
3.25.3 295 9/18/2024
Loading failed