DKNet.EfCore.DataAuthorization
10.0.10
See the version list below for details.
dotnet add package DKNet.EfCore.DataAuthorization --version 10.0.10
NuGet\Install-Package DKNet.EfCore.DataAuthorization -Version 10.0.10
<PackageReference Include="DKNet.EfCore.DataAuthorization" Version="10.0.10" />
<PackageVersion Include="DKNet.EfCore.DataAuthorization" Version="10.0.10" />
<PackageReference Include="DKNet.EfCore.DataAuthorization" />
paket add DKNet.EfCore.DataAuthorization --version 10.0.10
#r "nuget: DKNet.EfCore.DataAuthorization, 10.0.10"
#:package DKNet.EfCore.DataAuthorization@10.0.10
#addin nuget:?package=DKNet.EfCore.DataAuthorization&version=10.0.10
#tool nuget:?package=DKNet.EfCore.DataAuthorization&version=10.0.10
DKNet.EfCore.DataAuthorization
A .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.
Features
- Automatic global query filtering based on data ownership keys
- Interfaces for associating entities with owners (
IOwnedBy), providing ownership keys (IDataOwnerProvider), and integrating with DbContext (IDataOwnerDbContext) - Extension methods for easy setup via dependency injection (
EfCoreDataAuthSetup) - Support for multi-tenancy and secure data isolation
- .NET 9.0 compatible
Installation
Add the NuGet package to your project:
dotnet add package DKNet.EfCore.DataAuthorization
Usage
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
}
API
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.
License
MIT © 2026 drunkcoding
Repository
https://github.com/baoduy/DKNet
Contributing
Pull requests and issues are welcome!
| 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.0.10)
- DKNet.EfCore.Hooks (>= 10.0.10)
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 |
|---|---|---|
| 10.0.20 | 98 | 2/2/2026 |
| 10.0.19 | 90 | 1/21/2026 |
| 10.0.18 | 95 | 1/21/2026 |
| 10.0.17 | 96 | 1/19/2026 |
| 10.0.16 | 91 | 1/18/2026 |
| 10.0.15 | 96 | 1/18/2026 |
| 10.0.14 | 92 | 1/18/2026 |
| 10.0.13 | 98 | 1/17/2026 |
| 10.0.12 | 89 | 1/17/2026 |
| 10.0.11 | 96 | 1/17/2026 |
| 10.0.10 | 92 | 1/17/2026 |
| 10.0.9 | 96 | 1/16/2026 |
| 10.0.8 | 93 | 1/16/2026 |
| 10.0.7 | 189 | 11/28/2025 |
| 10.0.6 | 194 | 11/27/2025 |
| 10.0.5 | 193 | 11/24/2025 |
| 10.0.4 | 192 | 11/24/2025 |
| 10.0.3 | 375 | 11/21/2025 |
| 10.0.2 | 411 | 11/20/2025 |
| 0.0.1 | 409 | 11/19/2025 |