KitStack.Audit.EntityFrameworkCore
0.1.9
dotnet add package KitStack.Audit.EntityFrameworkCore --version 0.1.9
NuGet\Install-Package KitStack.Audit.EntityFrameworkCore -Version 0.1.9
<PackageReference Include="KitStack.Audit.EntityFrameworkCore" Version="0.1.9" />
<PackageVersion Include="KitStack.Audit.EntityFrameworkCore" Version="0.1.9" />
<PackageReference Include="KitStack.Audit.EntityFrameworkCore" />
paket add KitStack.Audit.EntityFrameworkCore --version 0.1.9
#r "nuget: KitStack.Audit.EntityFrameworkCore, 0.1.9"
#:package KitStack.Audit.EntityFrameworkCore@0.1.9
#addin nuget:?package=KitStack.Audit.EntityFrameworkCore&version=0.1.9
#tool nuget:?package=KitStack.Audit.EntityFrameworkCore&version=0.1.9
KitStack.Audit.EntityFrameworkCore
The EF Core capture source for KitStack.Audit. It provides a SaveChanges interceptor that
snapshots Added/Modified/Deleted entities into TrailDtos and forwards them to the registered
IAuditSink.
How it behaves
- Captures before the save (original values are intact) and writes after the save succeeds, so a rolled-back transaction never leaves orphan trails.
- Only acts on
DbContexts implementingIAuditableDbContextwithEnableAuditing == true. - Two-stage gate: an
IAuditEntityFilter(default: everything; orMarkerAuditEntityFilter<T>for aggregate roots) followed by the optional[AuditDefinition]+IAuditableEntityRegistrycheck. - Sink failures are logged and swallowed — auditing never breaks the business transaction.
Wiring
// 1. Mark your context
public class AppDbContext : DbContext, IAuditableDbContext
{
public bool EnableAuditing => true;
public string? AuditModule => "Sales";
}
// 2. Register the interceptor (restricting to aggregate roots in this example)
services.AddKitStackAuditCapture<IAggregateRoot>();
// 3. Attach it to the context
services.AddDbContext<AppDbContext>((sp, options) =>
{
options.UseSqlServer(connectionString);
options.AddInterceptors(sp.GetRequiredService<AuditSaveChangesInterceptor>());
});
IAuditContextAccessor, IAuditSink, and (optionally) IAuditableEntityRegistry must be
registered separately — typically by KitStack.Audit.AspNetCore or your application.
Notes
- Use client-generated keys (e.g. GUIDs) to capture primary keys; store-generated keys are temporary at capture time and are skipped.
- For the synchronous
SaveChanges()path the post-save write blocks on the async sink; preferSaveChangesAsync().
License
Apache-2.0
| Product | Versions 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. |
-
net10.0
- KitStack.Audit.Abstractions (>= 0.1.9)
- Microsoft.EntityFrameworkCore (>= 10.0.8)
- Microsoft.Extensions.DependencyInjection (>= 10.0.8)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.8)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.8)
- Microsoft.Extensions.Options (>= 10.0.8)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on KitStack.Audit.EntityFrameworkCore:
| Package | Downloads |
|---|---|
|
KitStack.Audit.AspNetCore
ASP.NET Core wiring for KitStack.Audit: one-call setup, sink selection, narration, and health checks. |
GitHub repositories
This package is not used by any popular GitHub repositories.