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.
$ dotnet add package DKNet.EfCore.DataAuthorizationA .NET library for secure, multi-tenant data authorization in Entity Framework Core. Enables automatic filtering of data based on ownership, supports DDD and API scenarios, and is designed for extensibility.
IOwnedBy), providing ownership keys (IDataOwnerProvider), and
integrating with DbContext (IDataOwnerDbContext)EfCoreDataAuthSetup)Add the NuGet package to your project:
dotnet add package DKNet.EfCore.DataAuthorization
Register the data authorization provider and setup in your DI container:
using Microsoft.Extensions.DependencyInjection;
using DKNet.EfCore.DataAuthorization;
services.AddAutoDataKeyProvider<MyDbContext, MyOwnerProvider>();
Implement IOwnedBy on your entities:
public class Document : IOwnedBy
{
public string? OwnedBy { get; private set; }
public void SetOwnedBy(string ownerKey) => OwnedBy = ownerKey;
}
Implement IDataOwnerProvider to supply ownership keys and accessible keys:
public class MyOwnerProvider : IDataOwnerProvider
{
public IEnumerable<string> GetAccessibleKeys() => ...; // e.g., from user context
public string GetOwnershipKey() => ...; // e.g., current user's tenant key
}
EfCoreDataAuthSetup.AddAutoDataKeyProvider<TDbContext, TProvider>(IServiceCollection): Registers automatic data key
management for a DbContext.IOwnedBy: Interface for entities supporting ownership, with methods to get/set the owner key.IDataOwnerProvider: Interface for providing accessible keys and ownership key for new entities.IDataOwnerDbContext: Interface for DbContexts supporting data authorization, exposing accessible keys.MIT © 2026 drunkcoding
https://github.com/baoduy/DKNet
Pull requests and issues are welcome!