DKNet.EfCore.Hooks 10.1.11

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

DKNet.EfCore.Hooks

NuGet NuGet Downloads License

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 shared SnapshotContext of changed entities
  • HookAsync base class with no-op virtual methods to override only what you use
  • AddDbContextWithHook<TDbContext> — registers the DbContext with the hook interceptor wired in
  • AddHook<TDbContext, THook>() — register a hook per DbContext type; idempotent, inherited by derived DbContext types
  • dbContext.DisableHooks() — reference-counted, disposable scope to suppress all hooks (e.g. during seeding/migrations)
  • Used internally by DKNet.EfCore.Events, DKNet.EfCore.AuditLogs, and DKNet.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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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.19 0 9/3/2026
10.1.18 0 9/3/2026
10.1.17 0 9/3/2026
10.1.16 0 9/3/2026
10.1.15 93 9/1/2026
10.1.14 89 9/1/2026
10.1.13 108 8/31/2026
10.1.12 213 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 169 8/19/2026
10.1.2 155 8/19/2026
10.1.1 142 8/19/2026
10.0.36 137 8/18/2026
Loading failed