DKNet.EfCore.Hooks
10.1.15
See the version list below for details.
dotnet add package DKNet.EfCore.Hooks --version 10.1.15
NuGet\Install-Package DKNet.EfCore.Hooks -Version 10.1.15
<PackageReference Include="DKNet.EfCore.Hooks" Version="10.1.15" />
<PackageVersion Include="DKNet.EfCore.Hooks" Version="10.1.15" />
<PackageReference Include="DKNet.EfCore.Hooks" />
paket add DKNet.EfCore.Hooks --version 10.1.15
#r "nuget: DKNet.EfCore.Hooks, 10.1.15"
#:package DKNet.EfCore.Hooks@10.1.15
#addin nuget:?package=DKNet.EfCore.Hooks&version=10.1.15
#tool nuget:?package=DKNet.EfCore.Hooks&version=10.1.15
DKNet.EfCore.Hooks
A pluggable before/after-SaveChanges interceptor pipeline for EF Core. Implement a small hook interface instead of overriding SaveChangesAsync, and let independent concerns (audit stamping, domain events, data ownership, …) share the same DbContext without knowing about each other.
Installation
dotnet add package DKNet.EfCore.Hooks
Features
IBeforeSaveHookAsync/IAfterSaveHookAsync/IHookAsync— implement the phase(s) you need against a sharedSnapshotContextof changed entitiesHookAsyncbase class with no-op virtual methods to override only what you useAddDbContextWithHook<TDbContext>— registers theDbContextwith the hook interceptor wired inAddHook<TDbContext, THook>()— register a hook perDbContexttype; idempotent, inherited by derivedDbContexttypesdbContext.DisableHooks()— reference-counted, disposable scope to suppress all hooks (e.g. during seeding/migrations)- Used internally by
DKNet.EfCore.Events,DKNet.EfCore.AuditLogs, andDKNet.EfCore.DataAuthorization
Quick start
using DKNet.EfCore.Hooks;
using DKNet.EfCore.Extensions.Snapshots;
using Microsoft.EntityFrameworkCore;
public sealed class AuditStampHook(ICurrentUserService currentUser) : IBeforeSaveHookAsync
{
public Task BeforeSaveAsync(SnapshotContext context, CancellationToken cancellationToken = default)
{
foreach (var entry in context.Entities)
{
if (entry.Entity is IAuditedProperties audited && entry.OriginalState == EntityState.Added)
audited.CreatedBy = currentUser.UserId;
}
return Task.CompletedTask;
}
}
// Registration
services.AddDbContextWithHook<AppDbContext>((provider, options) =>
options.UseSqlServer(connectionString));
services.AddHook<AppDbContext, AuditStampHook>();
Full documentation: https://github.com/baoduy/DKNet/blob/dev/docs/EfCore/DKNet.EfCore.Hooks.md
| 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
- DKNet.EfCore.Extensions (>= 10.1.15)
- DKNet.Fw.Extensions (>= 10.1.15)
- Microsoft.EntityFrameworkCore (>= 10.0.11)
NuGet packages (3)
Showing the top 3 NuGet packages that depend on DKNet.EfCore.Hooks:
| Package | Downloads |
|---|---|
|
DKNet.EfCore.Events
DKNet is an enterprise-grade .NET library collection focused on advanced EF Core extensions, dynamic predicate building, and the Specification pattern. It provides production-ready tools for building robust, type-safe, and testable data access layers, including dynamic LINQ support, LinqKit integration. Designed for modern cloud-native applications, DKNet enforces strict code quality, async best practices, and full documentation for all public APIs. Enterprise-grade .NET library suite for modern application development, featuring advanced EF Core extensions (dynamic predicates, specifications, LinqKit), robust Domain-Driven Design (DDD) patterns, and domain event support. DKNet empowers scalable, maintainable, and testable solutions with type-safe validation, async/await, XML documentation, and high code quality standards. Ideal for cloud-native, microservices, and enterprise architectures. |
|
|
DKNet.EfCore.DataAuthorization
DKNet is an enterprise-grade .NET library collection focused on advanced EF Core extensions, dynamic predicate building, and the Specification pattern. It provides production-ready tools for building robust, type-safe, and testable data access layers, including dynamic LINQ support, LinqKit integration. Designed for modern cloud-native applications, DKNet enforces strict code quality, async best practices, and full documentation for all public APIs. Enterprise-grade .NET library suite for modern application development, featuring advanced EF Core extensions (dynamic predicates, specifications, LinqKit), robust Domain-Driven Design (DDD) patterns, and domain event support. DKNet empowers scalable, maintainable, and testable solutions with type-safe validation, async/await, XML documentation, and high code quality standards. Ideal for cloud-native, microservices, and enterprise architectures. |
|
|
DKNet.EfCore.AuditLogs
DKNet is an enterprise-grade .NET library collection focused on advanced EF Core extensions, dynamic predicate building, and the Specification pattern. It provides production-ready tools for building robust, type-safe, and testable data access layers, including dynamic LINQ support, LinqKit integration. Designed for modern cloud-native applications, DKNet enforces strict code quality, async best practices, and full documentation for all public APIs. Enterprise-grade .NET library suite for modern application development, featuring advanced EF Core extensions (dynamic predicates, specifications, LinqKit), robust Domain-Driven Design (DDD) patterns, and domain event support. DKNet empowers scalable, maintainable, and testable solutions with type-safe validation, async/await, XML documentation, and high code quality standards. Ideal for cloud-native, microservices, and enterprise architectures. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 10.1.16 | 0 | 9/3/2026 |
| 10.1.15 | 89 | 9/1/2026 |
| 10.1.14 | 87 | 9/1/2026 |
| 10.1.13 | 107 | 8/31/2026 |
| 10.1.12 | 212 | 8/25/2026 |
| 10.1.11 | 147 | 8/24/2026 |
| 10.1.10 | 160 | 8/22/2026 |
| 10.1.9 | 188 | 8/22/2026 |
| 10.1.8 | 148 | 8/21/2026 |
| 10.1.7 | 160 | 8/21/2026 |
| 10.1.6 | 156 | 8/21/2026 |
| 10.1.5 | 233 | 8/20/2026 |
| 10.1.4 | 155 | 8/20/2026 |
| 10.1.3 | 168 | 8/19/2026 |
| 10.1.2 | 155 | 8/19/2026 |
| 10.1.1 | 142 | 8/19/2026 |
| 10.0.36 | 137 | 8/18/2026 |
| 10.0.35 | 137 | 8/5/2026 |
| 10.0.34 | 131 | 8/5/2026 |
| 10.0.33 | 141 | 8/4/2026 |