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
<PackageReference Include="IronAlpine.Data.EFCore.Mediator" Version="3.0.0" />
<PackageVersion Include="IronAlpine.Data.EFCore.Mediator" Version="3.0.0" />
<PackageReference Include="IronAlpine.Data.EFCore.Mediator" />
paket add IronAlpine.Data.EFCore.Mediator --version 3.0.0
#r "nuget: IronAlpine.Data.EFCore.Mediator, 3.0.0"
#:package IronAlpine.Data.EFCore.Mediator@3.0.0
#addin nuget:?package=IronAlpine.Data.EFCore.Mediator&version=3.0.0
#tool nuget:?package=IronAlpine.Data.EFCore.Mediator&version=3.0.0
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.EFCoreIronAlpine.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:
AutoClassicResultAware
Auto
- default
- resolves to
ResultAwarewhen 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:
- logging
- caching
- validation
- transaction
- 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
UnitOfWorkBehaviorenabled - 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:
DispatchDomainEventsInterceptornot wired into EF options
Fix:
- register EF Core mediator package correctly
- verify options interceptors include the dispatch interceptor
| Product | Versions 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. |
-
net10.0
- IronAlpine.Data.Abstractions (>= 3.0.0)
- IronAlpine.Data.EFCore (>= 3.0.0)
- IronAlpine.Framework.Abstractions (>= 2.0.0)
- IronAlpine.Mediator.Abstractions (>= 2.0.0)
- Microsoft.EntityFrameworkCore (>= 9.0.7)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.7)
-
net9.0
- IronAlpine.Data.Abstractions (>= 3.0.0)
- IronAlpine.Data.EFCore (>= 3.0.0)
- IronAlpine.Framework.Abstractions (>= 2.0.0)
- IronAlpine.Mediator.Abstractions (>= 2.0.0)
- Microsoft.EntityFrameworkCore (>= 9.0.7)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.7)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Stable mediator release with request/response, notification publish strategies, streaming, and dependency injection integration.