DKNet

DKNet Framework Documentation

DKNet is a suite of independent .NET 10 NuGet packages for building enterprise applications around Domain-Driven Design and Onion Architecture. There is no framework to adopt wholesale and no single AddDKNet() call: each package registers itself and can be used on its own, so you pull in only what a given DbContext, API, or worker actually needs.

28 packages are published to NuGet. One more, Aspire.Hosting.ServiceBus, is source-only in this repository (<IsPackable>false</IsPackable>) and documented anyway — it is an Aspire shared project you reference from an AppHost directly. DKNet.EfCore.Repos and DKNet.EfCore.Repos.Abstractions, the older generic-repository packages, were removed outright; see Migrating-Repos-To-Specifications if you are upgrading off them.

Quick Navigation

Getting Started

Core Documentation

Project Information

Which package do I need?

Sorted by the problem you have, not by namespace. Follow the link for the full API and gotchas.

I need to… Package
Give entities identity, audit fields, and a domain-event queue DKNet.EfCore.Abstractions
Have EF Core discover my IEntityTypeConfiguration<T> classes, apply global filters, seed data, use GUID v7 keys or SQL sequences DKNet.EfCore.Extensions
Query and persist without hand-rolling a repository per entity DKNet.EfCore.Specifications
Build a search/filter predicate whose criteria are only known at runtime DKNet.EfCore.Specifications — Dynamic Predicate Builder
Run my own code before and after every SaveChanges DKNet.EfCore.Hooks
Let a domain method raise an event that other code reacts to after the write commits DKNet.EfCore.Events
Record who changed which field, with sensitive values redacted DKNet.EfCore.AuditLogs
Stop one tenant or owner from reading another’s rows DKNet.EfCore.DataAuthorization
Encrypt a column without changing the queries that read it DKNet.EfCore.Encryption
Stop hand-writing DTOs that mirror entities DKNet.EfCore.DtoGenerator
Check for or create a table at runtime, whatever the relational provider DKNet.EfCore.Relational.Helpers
Separate commands from queries and stop calling SaveChangesAsync in handlers DKNet.SlimBus.Extensions
Generate CRUD requests, handlers, and endpoints from an attributed entity member DKNet.SlimBus.Generators
Map minimal-API endpoint groups by convention and turn a Result into ProblemDetails DKNet.AspCore.Extensions
Make a POST/PUT/PATCH safe for a client to retry DKNet.AspCore.Idempotency on its own for local development, plus one store package for deployed traffic
Run a job exactly once at start-up, before traffic arrives DKNet.AspCore.Tasks
Store files without binding the application to one cloud DKNet.Svc.BlobStorage.Abstractions plus one adapter
Encrypt, sign, or hash a value in ordinary application code DKNet.Svc.Encryption
Render Markdown or HTML to a PDF file DKNet.Svc.PdfGenerators
Fill bracketed tokens in a template string from an object or a dictionary DKNet.Svc.Transformation
Generate a password, token, or other secret DKNet.RandomCreator
Scan assemblies for types, or reach for a string/enum/DateTime/reflection helper DKNet.Fw.Extensions
Give a local Aspire AppHost its own Azure Service Bus emulator Aspire.Hosting.ServiceBus (source-only)

Component Documentation

Core Framework

Foundation utilities that sit at the bottom of the dependency graph and pull in nothing else from DKNet.

Entity Framework Core Extensions

Entity base classes, the specification pattern, and the SaveChanges interceptor pipeline everything else hangs off.

Messaging & CQRS

SlimMessageBus integration: CQRS contracts, automatic save, and the CRUD source generator.

Service Layer

Application-level services with no dependency on the EF Core packages.

ASP.NET Core Utilities

Start-up orchestration, minimal-API glue, and idempotency for web and API workloads.

Aspire Integrations

Infrastructure orchestration helpers for .NET Aspire AppHost projects.

Architecture Overview

Every ring of the onion is a separate package, and every dependency points inward. The Architecture Guide walks the same picture in detail, adds the package dependency graph, and traces a request and a domain event end to end.

The DKNet onion: presentation packages at the top, the application ring below them, the EF Core infrastructure ring in the middle, and DKNet.EfCore.Abstractions plus the dependency-free foundation packages at the bottom. Every arrow is a project reference pointing inward.

Key architectural principles

  1. Dependency inversion — inner rings never reference outer ones; the arrows above are real ProjectReference entries in src/.
  2. Separation of concerns — one package, one responsibility, and no package that only exists to aggregate others.
  3. Domain-centricity — business rules live in entity methods; DKNet.EfCore.Abstractions is the only package a domain model has to see.
  4. Event-driven where it helps — domain events are queued on the entity and dispatched after the write commits, so a domain method never talks to a bus.
  5. Specifications, not a repository per entity — one injected IRepositorySpec serves every entity type; the entity comes from the specification passed to each call.

Getting started

  1. Pick the packages you need — start from the Which package do I need? table above.
  2. Read the ring it lives in — the Architecture Guide explains what a package can and cannot depend on.
  3. Wire it up — Configuration & Setup covers the four registration conventions the packages share.
  4. Copy a working example — Examples & Recipes, or the SlimBus.ApiEndpoints template in the DKNet.Templates repository.

Contributing to documentation

Corrections and additions are welcome. Open an issue describing the problem, or send a pull request that follows the structure and voice of the surrounding pages — the canonical page structure is the Package Documentation Template; see also the Contributing Guide.

Every claim on these pages should be traceable to src/, a test, or a config file. If you find one that is not, that is a bug worth reporting in the DKNet repository.