Innovabit.DotNet.Interceptors.Transactions.EntityFrameworkCore 3.0.133

There is a newer version of this package available.
See the version list below for details.
dotnet add package Innovabit.DotNet.Interceptors.Transactions.EntityFrameworkCore --version 3.0.133
                    
NuGet\Install-Package Innovabit.DotNet.Interceptors.Transactions.EntityFrameworkCore -Version 3.0.133
                    
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="Innovabit.DotNet.Interceptors.Transactions.EntityFrameworkCore" Version="3.0.133" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Innovabit.DotNet.Interceptors.Transactions.EntityFrameworkCore" Version="3.0.133" />
                    
Directory.Packages.props
<PackageReference Include="Innovabit.DotNet.Interceptors.Transactions.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 Innovabit.DotNet.Interceptors.Transactions.EntityFrameworkCore --version 3.0.133
                    
#r "nuget: Innovabit.DotNet.Interceptors.Transactions.EntityFrameworkCore, 3.0.133"
                    
#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 Innovabit.DotNet.Interceptors.Transactions.EntityFrameworkCore@3.0.133
                    
#: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=Innovabit.DotNet.Interceptors.Transactions.EntityFrameworkCore&version=3.0.133
                    
Install as a Cake Addin
#tool nuget:?package=Innovabit.DotNet.Interceptors.Transactions.EntityFrameworkCore&version=3.0.133
                    
Install as a Cake Tool

Innovabit.DotNet.Interceptors.Transactions.EntityFrameworkCore

Entity Framework Core provider for Innovabit.DotNet.Interceptors.Transactions.Abstractions: [Transactional] methods run inside a transaction opened on your DbContext's own connection, so every SaveChanges they make takes part in it.

Usage

services.AddDbContext<OrderDbContext>(o => o.UseSqlServer(connectionString));

services
    .AddInterceptors()
    .AddEntityFrameworkCoreTransactions<OrderDbContext>();

services.AddScopedWithInterception<IOrderService, OrderService>();
public class OrderService(OrderDbContext db, IInventoryService inventory) : IOrderService
{
    [Transactional]
    public async Task PlaceAsync(Order order, CancellationToken cancellationToken)
    {
        db.Orders.Add(order);
        await db.SaveChangesAsync(cancellationToken);

        // Joins the same transaction: nothing is persisted unless both steps succeed.
        await inventory.ReserveAsync(order.Lines, cancellationToken);
    }
}

The DbContext must be registered with a scoped lifetime (what AddDbContext does by default), so the interceptor and the intercepted method share the same connection.

Provider notes

[Transactional] property Behaviour here
Propagation Required, Supports, Mandatory and Never work as documented. RequiresNew throws NotSupportedException when a transaction is already in progress — a DbContext holds one connection, which cannot carry two independent transactions. Use the SystemTransactions provider, or a second DbContext.
IsolationLevel Passed straight to Database.BeginTransaction(IsolationLevel).
TimeoutSeconds EF Core has no transaction timeout, so it is applied as the command timeout for the statements issued inside the transaction. The context's previous command timeout is restored afterwards.
ReadOnly The transaction is opened and then rolled back instead of committed. Tracking behaviour is left untouched.

Retrying execution strategies

With a retrying execution strategy (EnableRetryOnFailure), EF Core refuses transactions opened outside it, so the whole [Transactional] method runs inside it and is run again after a transient failure, on a cleared change tracker. Keep in mind:

  • Anything else the method does (an e-mail, an HTTP call) happens again too.
  • The commit is not retried: if the connection is lost while committing, it may have gone through, and running the method again would do the work twice. That failure reaches the caller.
  • If the context was already tracking entities when the method was called, they would be lost, so it fails with an InvalidOperationException instead of retrying. The first attempt is not affected.
  • Once the strategy gives up, the caller gets EF Core's RetryLimitExceededException.

License

MIT

Product Compatible and additional computed target framework versions.
.NET 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.  net11.0 is compatible. 
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.136 47 12/5/2026
3.0.135 105 11/30/2026
3.0.134 97 11/30/2026
3.0.133 85 11/30/2026
3.0.132 90 11/30/2026
3.0.129 89 11/30/2026
3.0.128 94 11/30/2026
3.0.127 106 11/30/2026
3.0.126 106 11/30/2026
3.0.125 107 11/30/2026
3.0.124 104 11/28/2026
3.0.123 98 11/28/2026
3.0.122 116 11/21/2026
2.0.121 91 11/21/2026
2.0.120 101 11/21/2026
2.0.119 117 11/14/2026
2.0.118 119 11/7/2026
2.0.117 122 10/31/2026
2.0.116 113 10/26/2026
2.0.115 121 10/17/2026
Loading failed