IronAlpine.Data.EFCore.Mediator 3.0.0

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

IronAlpine.Data.EFCore.Mediator

IronAlpine.Data.EFCore.Mediator provides mediator pipeline coordination for EF Core-backed services.

It handles:

  • transaction behavior
  • unit-of-work behavior
  • domain-event dispatch interception
  • command-intent auditing behavior

Why

Use this package when your application uses IronAlpine.Mediator and EF Core together and you want transaction boundaries, domain event dispatch, and audit intent handled consistently.

Install

dotnet add package IronAlpine.Data.EFCore.Mediator

Prerequisites

  • IronAlpine.Data.EFCore
  • IronAlpine.Mediator.DependencyInjection

Quick Start

builder.Services.AddIronAlpineDataEfCoreMediator<AppDbContext>(options =>
{
    options.UseTransactionBehavior = false;
    options.UseUnitOfWorkBehavior = false;
    options.Transaction.Mode = TransactionMode.ResultAware;
});

That is the recommended DPS-style deterministic mode when behavior order is controlled manually in application registration.

Public Surface

Main registration method:

  • AddIronAlpineDataEfCoreMediator<TDbContext>(...)

Main runtime pieces:

  • TransactionBehavior<TRequest, TResponse>
  • UnitOfWorkBehavior<TRequest, TResponse>
  • AuditingBehavior<TRequest, TResponse>
  • DispatchDomainEventsInterceptor

Options Deep Dive

Type: DataEfCoreMediatorOptions

UseTransactionBehavior

  • default: true
  • automatically registers transaction pipeline behavior
  • disable when the application wants explicit manual behavior ordering

UseUnitOfWorkBehavior

  • default: true
  • automatically registers save behavior
  • disable when handlers own SaveChanges*() timing explicitly

Transaction.Mode

Values:

  • Auto
  • Classic
  • ResultAware
Auto
  • default
  • resolves to ResultAware when response supports transactional result semantics
  • otherwise behaves like Classic
Classic
  • commit on success path
  • rollback on exception
ResultAware
  • rollback and skip save when the response is a failed transactional result
  • best fit when handlers return result objects instead of throwing for business failures

Behavior Order

Recommended order in manually controlled pipelines:

  1. logging
  2. caching
  3. validation
  4. transaction
  5. unit of work

This keeps validation and cache short-circuiting outside the transaction boundary.

Domain Event Dispatch

DispatchDomainEventsInterceptor is part of the package because domain-event dispatch is not optional in DDD-oriented write services.

Best practice:

  • keep it explicitly wired into EF options
  • do not silently drop it just because a service is currently projection-heavy
  • future aggregates will rely on it

Auditing Behavior

AuditingBehavior captures command intent, not only row mutation.

Use it when you want:

  • command payload audit trails
  • actor-aware command logging
  • operational forensic support beyond entity-level audit columns

Combinations

EFCore.Mediator + Validation.Fluent

Validate first, then open transaction.

EFCore.Mediator + Messaging.InboxOutbox.EFCore

Use when command handlers publish integration events and need transactionally safe outbox persistence.

EFCore.Mediator + Logging.Serilog

Use logging behavior ahead of transaction and unit-of-work behaviors for clean request-level diagnostics.

Troubleshooting

SaveChanges happens twice

Cause:

  • auto UnitOfWorkBehavior enabled
  • handlers also call SaveChangesAsync() manually

Fix:

  • choose one model deliberately
  • in DPS-style applications, disable auto UoW behavior

Failed Result still commits

Cause:

  • transaction mode not set to ResultAware

Fix:

  • configure Transaction.Mode = TransactionMode.ResultAware

Domain events never dispatch

Cause:

  • DispatchDomainEventsInterceptor not wired into EF options

Fix:

  • register EF Core mediator package correctly
  • verify options interceptors include the dispatch interceptor
Product Compatible and additional computed target framework versions.
.NET 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

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
3.0.0 669 4/20/2026
2.2.0 101 4/17/2026
2.1.2 259 4/14/2026
2.1.1 158 4/10/2026
2.1.0 365 4/8/2026
2.0.10 101 4/8/2026
2.0.7 340 4/4/2026
Loading failed

Stable mediator release with request/response, notification publish strategies, streaming, and dependency injection integration.