DKNet.EfCore.DataAuthorization 13.3.1

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

DKNet.EfCore.DataAuthorization

Filter owned rows and stamp ownership for .NET developers building tenant-aware EF Core applications.

✨ Why use it?

  • Apply ownership checks to queries without repeating a Where clause.
  • Deny owned-row reads when the accessible-key list is empty.
  • Fill a new row's blank owner and revert inaccessible ownership changes before saving.

🚀 Quick Start

Use a .NET 10 console project. Install the packages, then replace Program.cs with the example.

dotnet new console -f net10.0 -n EfCoreDemo
cd EfCoreDemo
dotnet add package DKNet.EfCore.DataAuthorization
dotnet add package Microsoft.EntityFrameworkCore.Sqlite --version 10.0.12
using DKNet.EfCore.DataAuthorization;
using DKNet.EfCore.Hooks;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;

using var connection = new Microsoft.Data.Sqlite.SqliteConnection("Data Source=:memory:");
connection.Open();
var services = new ServiceCollection();
services.AddLogging();
services.AddDataOwnerProvider<DemoDb, DemoOwner>();
services.AddDbContextWithHook<DemoDb>(o =>
    o.UseSqlite(connection).UseAutoConfigModel<DemoDb>());
using var provider = services.BuildServiceProvider();
using var scope = provider.CreateScope();
await using var db = scope.ServiceProvider.GetRequiredService<DemoDb>();
await db.Database.EnsureCreatedAsync();
db.Add(new Invoice { Name = "Coffee" });
await db.SaveChangesAsync();
db.ChangeTracker.Clear();
var invoice = await db.Invoices.SingleAsync();
Console.WriteLine(invoice.OwnedBy); // tenant-a

public sealed class DemoOwner : IDataOwnerProvider
{
    public string? GetOwnershipKey() => "tenant-a";
}
public sealed class DemoDb(DbContextOptions<DemoDb> options, IDataOwnerProvider owner)
    : DbContext(options), IDataOwnerDbContext
{
    public DbSet<Invoice> Invoices => Set<Invoice>();
    public IEnumerable<string> AccessibleKeys => owner.GetAccessibleKeys();
}
public sealed class Invoice : IOwnedBy
{
    public int Id { get; set; }
    public string Name { get; set; } = "";
    public string OwnedBy { get; private set; } = "";
    public void AssignOwner(string key) => OwnedBy = key;
}

Run with dotnet run.

Documentation

Guide Read when
Package overview Start with architecture and the end-to-end flow.
Filter owned rows Wire the global filter and explicit unrestricted access.
Stamp and guard ownership Set owners and compose tenant and user audit identity.
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

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
13.3.1 92 10/26/2026
13.3.0 128 10/22/2026
13.2.8 91 10/22/2026
13.2.7 142 10/11/2026
13.2.6 89 10/10/2026
13.2.5 130 10/2/2026
13.2.4 97 10/1/2026
13.2.3 98 10/1/2026
13.2.2 98 10/1/2026
13.2.1 101 10/1/2026
13.2.0 104 10/1/2026
13.1.3 145 9/21/2026
13.1.2 108 9/18/2026
13.1.1 107 9/18/2026
13.1.0 112 9/18/2026
13.0.2 112 9/18/2026
13.0.1 99 9/18/2026
13.0.0 106 9/18/2026
12.0.0 117 9/17/2026
11.0.0 190 9/17/2026
Loading failed