DKNet Framework

A suite of 28 independent .NET 10 NuGet packages for building enterprise applications around Domain-Driven Design
and Onion Architecture.
✨ Why use it?
- Take only what your
DbContext or API needs. Each package is opt-in and registers itself: there is no
AddDKNet() and no package that only aggregates others.
- One repository for every entity.
DKNet.EfCore.Specifications gives you one injected IRepositorySpec that
takes a reusable specification, instead of a hand-rolled repository per entity.
- Cross-cutting rules stay out of domain code. Domain events, audit logs, row-level data authorization and column
encryption attach to the
DbContext through the SaveChanges hook pipeline or a value converter.
- CQRS without MediatR.
DKNet.SlimBus.Extensions builds commands, queries and event consumers on
SlimMessageBus, saves the DbContext after a successful write and forwards domain events onto the bus.
- ASP.NET Core and service glue included. Idempotent endpoints, startup background tasks, minimal-API endpoint
groups, blob storage adapters, PDF generation and .NET Aspire integrations ship as their own packages.
🚀 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.Specifications
dotnet add package Microsoft.EntityFrameworkCore.Sqlite --version 10.0.12
using DKNet.EfCore.Specifications;
using DKNet.EfCore.Specifications.Definitions;
using DKNet.EfCore.Specifications.Extensions;
using DKNet.EfCore.Specifications.Repositories;
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.AddDbContext<DemoDb>(o => o.UseSqlite(connection));
services.AddSpecRepo<DemoDb>();
using var provider = services.BuildServiceProvider();
using var scope = provider.CreateScope();
await using var db = scope.ServiceProvider.GetRequiredService<DemoDb>();
await db.Database.EnsureCreatedAsync();
var repo = scope.ServiceProvider.GetRequiredService<IRepositorySpec>();
await repo.AddRangeAsync(new[]
{
new Product { Name = "Coffee", Price = 12 },
new Product { Name = "Tea", Price = 6 }
});
await repo.SaveChangesAsync();
var rows = await repo.ToListAsync(new MinimumPrice(10));
Console.WriteLine(rows.Single().Name); // Coffee
public sealed class DemoDb(DbContextOptions<DemoDb> options) : DbContext(options)
{
public DbSet<Product> Products => Set<Product>();
}
public sealed class Product
{
public int Id { get; set; }
public string Name { get; set; } = "";
public int Price { get; set; }
}
public sealed class MinimumPrice : Specification<Product>
{
public MinimumPrice(int minimum)
{
WithFilter(p => p.Price >= minimum);
AddOrderBy(p => p.Id);
AsNoTracking();
}
}
Run with dotnet run. Prints Coffee.
Not sure which packages you need? The
Which package do I need? table maps problems to packages. For a complete
reference application, see the SlimBus.ApiEndpoints template.
Documentation
