Innovabit.DotNet.Interceptors.Audit.EntityFrameworkCore 2.0.117

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

Innovabit.DotNet.Interceptors.Audit.EntityFrameworkCore

Entity Framework Core sink for Innovabit.DotNet.Interceptors.Audit.Abstractions: every [Audited] call becomes an AuditRecord row in your database.

Usage

// A factory, not just AddDbContext — see "Why a separate context" below.
services.AddDbContextFactory<BillingDbContext>(o => o.UseSqlServer(connectionString));

services
    .AddInterceptors()
    .AddEntityFrameworkCoreAudit<BillingDbContext>();

services.AddScopedWithInterception<IRefundService, RefundService>();

Add the table to your model and create a migration for it:

public class BillingDbContext(DbContextOptions<BillingDbContext> options) : DbContext(options)
{
    protected override void OnModelCreating(ModelBuilder modelBuilder)
        => modelBuilder.ApplyAuditRecordConfiguration();
}
dotnet ef migrations add AddAuditRecords

Why a separate context

Each entry is written on a context taken from IDbContextFactory<TContext>, not on the context the audited method happens to be using. That is what makes the trail trustworthy:

  • The audit row survives a rollback of the business transaction. A refund that failed halfway still leaves a record that it was attempted — which is precisely the case an auditor asks about.
  • Auditing cannot flush the caller's pending work. Saving on a shared context would persist whatever half-finished changes were sitting in its change tracker, as a side effect of writing an audit row.

The factory can live alongside a regular AddDbContext<TContext>(); registering both is normal.

The table

AuditRecords, with indexes on OccurredAt and Action — the two things an audit trail is always queried by.

Column Notes
Id Surrogate key, database-generated.
OccurredAt When the call started.
Action, Category From [Audited], or TypeName.MethodName.
TypeName, MethodName What was called.
Subject Who did it, from IAuditSubjectAccessor.
CorrelationId Trace id of the ambient Activity, to line the row up with a trace.
Succeeded, ExceptionType, ExceptionMessage How it ended.
DurationMs How long it took.
Arguments, Result Serialized by the registered IAuditSerializer (JSON by default).

Arguments, Result and ExceptionMessage are deliberately unbounded; the rest carry lengths.

License

MIT

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

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.0.117 46 10/31/2026
2.0.116 89 10/26/2026
2.0.115 101 10/17/2026
2.0.114 92 10/10/2026
2.0.113 105 10/3/2026
2.0.112 97 9/28/2026
2.0.111 96 9/28/2026
2.0.110 106 9/27/2026
2.0.109 107 9/26/2026
2.0.108 97 9/26/2026
2.0.107 105 9/26/2026
2.0.106 109 9/25/2026
2.0.105 101 9/25/2026
1.0.0.104 91 9/25/2026
1.0.0.103 89 9/25/2026
1.0.0.102 102 9/25/2026
1.0.0.101 99 9/25/2026
1.0.0.100 99 9/25/2026