DKNet.EfCore.DataAuthorization
10.1.10
dotnet add package DKNet.EfCore.DataAuthorization --version 10.1.10
NuGet\Install-Package DKNet.EfCore.DataAuthorization -Version 10.1.10
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.DataAuthorization" Version="10.1.10" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="DKNet.EfCore.DataAuthorization" Version="10.1.10" />
<PackageReference Include="DKNet.EfCore.DataAuthorization" />
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.DataAuthorization --version 10.1.10
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: DKNet.EfCore.DataAuthorization, 10.1.10"
#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.DataAuthorization@10.1.10
#: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.DataAuthorization&version=10.1.10
#tool nuget:?package=DKNet.EfCore.DataAuthorization&version=10.1.10
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
DKNet.EfCore.DataAuthorization
Row-level, ownership-based data authorization for EF Core: an automatic global query filter plus a SaveChanges
hook, so multi-tenant or per-user data isolation is enforced by the persistence layer instead of by convention in
every query.
Install
dotnet add package DKNet.EfCore.DataAuthorization
Features
IOwnedBy— marker interface entities implement to opt into ownership-based filtering and stamping.- Automatic global query filter — every
IOwnedByentity is scoped toIDataOwnerDbContext.AccessibleKeysautomatically; deny-by-default when empty, with an explicitIsUnrestrictedAccessescape hatch for admin/system contexts. Not bypassable via specificationIsIgnoreQueryFilters. - Automatic ownership stamping — a
SaveChangeshook stamps the current owner key onto newly addedIOwnedByentities (andCreatedBy/CreatedOnwhen the entity is also audited), and reverts any attempt to silently reassign an existing row's owner to a key the caller can't access. - One DI call to wire it up —
AddDataOwnerProvider<TDbContext, TProvider>()registers the query filter, the hook, and yourIDataOwnerProviderimplementation together.
Quick start
public class Invoice : IOwnedBy
{
public string OwnedBy { get; private set; } = string.Empty;
}
public class AppDbContext(DbContextOptions<AppDbContext> options) : DbContext(options), IDataOwnerDbContext
{
public IEnumerable<string> AccessibleKeys { get; init; } = [];
protected override void OnModelCreating(ModelBuilder modelBuilder)
=> modelBuilder.UseAutoConfigModel(); // required for the global query filter to apply
}
public sealed class TenantOwnerProvider(ICurrentTenant currentTenant) : IDataOwnerProvider
{
public string? GetOwnershipKey() => currentTenant.TenantId;
}
services
.AddDataOwnerProvider<AppDbContext, TenantOwnerProvider>()
.AddDbContextWithHook<AppDbContext>(options => options.UseSqlServer(connectionString));
Full documentation, configuration options, and gotchas: DKNet.EfCore.DataAuthorization docs
| 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net10.0
- DKNet.EfCore.Extensions (>= 10.1.10)
- DKNet.EfCore.Hooks (>= 10.1.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.1.10 | 32 | 8/22/2026 |
| 10.1.9 | 48 | 8/22/2026 |
| 10.1.8 | 41 | 8/21/2026 |
| 10.1.7 | 68 | 8/21/2026 |
| 10.1.6 | 49 | 8/21/2026 |
| 10.1.5 | 71 | 8/20/2026 |
| 10.1.4 | 77 | 8/20/2026 |
| 10.1.3 | 82 | 8/19/2026 |
| 10.1.2 | 75 | 8/19/2026 |
| 10.1.1 | 78 | 8/19/2026 |
| 10.0.36 | 92 | 8/18/2026 |
| 10.0.35 | 107 | 8/5/2026 |
| 10.0.34 | 95 | 8/5/2026 |
| 10.0.33 | 100 | 8/4/2026 |
| 10.0.32 | 97 | 8/3/2026 |
| 10.0.31 | 112 | 7/21/2026 |
| 10.0.30 | 97 | 7/21/2026 |
| 10.0.29 | 132 | 6/22/2026 |
| 10.0.27 | 136 | 5/22/2026 |
| 10.0.26 | 108 | 5/19/2026 |
Loading failed