DKNet

DKNet.EfCore.Abstractions

Entity identities, event contracts and policy attributes for .NET developers modelling a domain without the EF Core runtime.

✨ Why use it?

🚀 Quick Start

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

dotnet new console -f net10.0 -n EfCoreDemo
cd EfCoreDemo
dotnet add package DKNet.EfCore.Abstractions
using DKNet.EfCore.Abstractions.Entities;
using DKNet.EfCore.Abstractions.Events;

var order = new Order();
order.Place();
Console.WriteLine(order.GetEvents().Events.Length); // 1
order.ClearEvents();
Console.WriteLine(order.GetEvents().Events.Length); // 0

public sealed class Order : Entity
{
    public void Place() => AddEvent(new OrderPlaced(Id));
}
public sealed record OrderPlaced(Guid OrderId) : EventItem;

Run with dotnet run.

🏗️ Architecture

The domain application derives Entity and AuditedEntity, declares attributes and exposes contracts that runtime consumers read.

Abstractions has no service registration or background work. Entity queues belong to each entity; attributes and interfaces are consumed by the host runtime packages. Direct references are EF Core Abstractions, annotations and FluentResults, rather than the EF Core runtime.

🔄 How it works

Order queues a plain event, GetEvents copies the queue, and ClearEvents explicitly empties it.

The Quick Start only exercises the in-memory queue. It does not publish or persist anything; use Events and Hooks for dispatch around SaveChangesAsync.

🧩 Features