Entity identities, event contracts and policy attributes for .NET developers modelling a domain without the EF Core runtime.
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.
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.
The Quick Start only exercises the in-memory queue. It does not publish or persist anything; use Events and Hooks for dispatch around SaveChangesAsync.
Entity<TKey> for an identity plus event queues, or implement the covariant IEntity<out TKey> contract yourself.AuditedEntity<TKey> or its Guid specialization to store audit identity and timestamps.IConcurrencyEntity<TType> to give infrastructure a consistent RowVersion property and setter.ISoftDeletableEntity when deletion records a flag, user and time instead of removing the object.Entity<TKey> implements IEventEntity with separate queues for event objects and event types.[RaisesEvent] declarations to an entity for create, update or delete payloads.[SqlSequence] on an enum and [Sequence] on each member that represents a database sequence.