CoreEx.EntityFrameworkCore
4.0.0-preview-1
dotnet add package CoreEx.EntityFrameworkCore --version 4.0.0-preview-1
NuGet\Install-Package CoreEx.EntityFrameworkCore -Version 4.0.0-preview-1
<PackageReference Include="CoreEx.EntityFrameworkCore" Version="4.0.0-preview-1" />
<PackageVersion Include="CoreEx.EntityFrameworkCore" Version="4.0.0-preview-1" />
<PackageReference Include="CoreEx.EntityFrameworkCore" />
paket add CoreEx.EntityFrameworkCore --version 4.0.0-preview-1
#r "nuget: CoreEx.EntityFrameworkCore, 4.0.0-preview-1"
#:package CoreEx.EntityFrameworkCore@4.0.0-preview-1
#addin nuget:?package=CoreEx.EntityFrameworkCore&version=4.0.0-preview-1&prerelease
#tool nuget:?package=CoreEx.EntityFrameworkCore&version=4.0.0-preview-1&prerelease
CoreEx.EntityFrameworkCore
Provides the Entity Framework Core integration layer:
EfDb<TDbContext>as the CoreEx-EF bridge,EfDbModel<TModel>andEfDbMappedModel<TValue, TModel, TMapper>for typed CRUD + query operations,EfDbExtensionsfor pagedIQueryable<T>mapping helpers,EfDbInvokerfor OpenTelemetry tracing, and EFValueConverterbridges 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 underlyingIDatabase.CurrentTransaction, so raw SQL commands and EF operations participate in the same ADO.NET transaction. - 📖 Typed CRUD:
EfDbModel<TModel>providesGetAsync,CreateAsync,UpdateAsync,DeleteAsyncwith automatic ETag/concurrency-token validation, tenant isolation, logical-delete filtering, and change-log stamping. - 🔁 Mapped CRUD:
EfDbMappedModel<TValue, TModel, TMapper>layers aIBiDirectionMapper<TValue, TModel>overEfDbModel<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 fluentEfDbQuery<TModel>that appliesQueryArgsConfigfilter and orderby, tenant and logical-delete predicates, and paging. - 📄 Paged IQueryable extensions:
EfDbExtensions.ToMappedItemsResultAsync,ToItemsResultAsync,ToMappedCollectionAsyncconvert anIQueryable<TSource>to pagedItemsResult<T>or collections with a mapper function orIMapper<T>. - 🏷️ ETag / concurrency token:
EfDbArgs.CheckETagcompares the incomingETagagainst the current entity's concurrency token before update/delete, throwingConcurrencyExceptionon mismatch. - 🔒 Multi-tenancy filtering:
EfDbModelautomatically addsTenantId == executionContext.TenantIdpredicates for entities implementingIReadOnlyTenantId. - 🗑️ Logical delete: Entities implementing
IReadOnlyLogicallyDeletedare soft-deleted (IsDeleted = true) onDeleteAsyncrather than physically removed, and filtered out ofGetAsync/Query. - 🔌 ValueConverter bridge:
ValueConverterBridge<TModel, TProvider>andJsonElementStringEfConverterallow CoreExIConverter<T, U>implementations to be used directly as EF CoreValueConverterinstances inOnModelCreating. - 📡 OpenTelemetry:
EfDbInvokerwraps everyEfDboperation with anActivityspan 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. |
Related Namespaces
CoreEx.Data-IUnitOfWork,DataResult,QueryArgsConfig; EF unit-of-work is typically composed usingEfDbwith an outbox publisher.CoreEx.Database-IDatabaseis bridged intoEfDb<TDbContext>for transaction sharing and raw SQL fallback;IDatabaseUnitOfWorkcan wrapEfDb.CoreEx.Mapping-IBiDirectionMapper<TValue, TModel>is the mapper contract used byEfDbMappedModel;Mapper.MapStandardFromhandles standard entity-contract properties.CoreEx.Invokers-EfDbInvokerextendsInvokerBase<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 | Versions 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. |
-
net10.0
- CoreEx (>= 4.0.0-preview-1)
- CoreEx.Data (>= 4.0.0-preview-1)
- CoreEx.Database (>= 4.0.0-preview-1)
- Microsoft.EntityFrameworkCore (>= 10.0.3)
- Microsoft.EntityFrameworkCore.Relational (>= 10.0.3)
-
net8.0
- CoreEx (>= 4.0.0-preview-1)
- CoreEx.Data (>= 4.0.0-preview-1)
- CoreEx.Database (>= 4.0.0-preview-1)
- Microsoft.EntityFrameworkCore (>= 8.0.24)
- Microsoft.EntityFrameworkCore.Relational (>= 8.0.24)
-
net9.0
- CoreEx (>= 4.0.0-preview-1)
- CoreEx.Data (>= 4.0.0-preview-1)
- CoreEx.Database (>= 4.0.0-preview-1)
- Microsoft.EntityFrameworkCore (>= 9.0.13)
- Microsoft.EntityFrameworkCore.Relational (>= 9.0.13)
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 |