Vorn.EntityManagement 4.6.0-beta

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

Vorn.EntityManagement

Philosophy

Vorn.EntityManagement is the foundation of the Vorn data platform. The package embraces CQRS and mediator-driven orchestration to keep entity workflows composable, testable, and cache aware. The library intentionally separates persistence logic from the domain model through command/query records so that your application can evolve without sacrificing correctness. The design centers on three pillars:

  1. Explicit intent – CRUD operations are expressed as MediatR requests so that every write or query is observable and interceptable by cross-cutting behaviors (logging, validation, or auditing).
  2. Cache-first experience – The provided cache abstractions (IEntityCache, EntityMemoryCache, and invalidation services) ensure that entity lifetimes are controlled in one location while avoiding stale reads.
  3. Descriptor-driven access – Entities expose typed descriptors (EntityDescriptor) that filter reads, updates, and removals. This promotes discoverable API surface instead of ad-hoc query objects.

Package structure

The package exposes a cohesive set of primitives that can be combined in vertical slices. Core components include:

  • Entity – Base record for aggregate roots with identity helpers.
  • EntityDescriptor – Value object representing the filter used in queries and bulk operations.
  • EntityService<TEntity, TDescriptor, TDto, TDescriptorDto> – High-level service that wraps MediatR and mapping delegates to provide DTO-friendly operations.
  • Commands and queries – Records such as AddEntityCommand, UpdateEntitiesCommand, RemoveEntitiesByDescriptorCommand, and GetEntityByIdQuery express the intent for MediatR handlers in your application.
  • Infrastructure helpers – Caching (EntityCacheInvalidationService, EntityMemoryCache), repository abstraction (IEntityRepository), and notification pipeline support (EntityNotification).

These building blocks allow you to layer domain logic, infrastructure, and presentation independently while reusing the same entity orchestration flows.

Getting started

1. Install the package

Install-Package Vorn.EntityManagement

2. Define your entity

public sealed class Document : Entity
{
    public string Title { get; init; } = string.Empty;
    public string Body { get; init; } = string.Empty;
}

public sealed class DocumentDescriptor : EntityDescriptor
{
    public required string TenantId { get; init; }
    public override IReadOnlyDictionary<string, object?> AsDictionary()
        => new Dictionary<string, object?> { ["tenant"] = TenantId };
}

3. Implement handlers

Handlers react to commands and queries using your persistence stack (Entity Framework Core, Dapper, etc.).

internal sealed class AddDocumentHandler(IMediator mediator, IDocumentDbContext db) 
    : IRequestHandler<AddEntityCommand<Document, DocumentDescriptor>, Document?>
{
    public async Task<Document?> Handle(
        AddEntityCommand<Document, DocumentDescriptor> request,
        CancellationToken cancellationToken)
    {
        db.Documents.Add(request.Entity);
        await db.SaveChangesAsync(cancellationToken);
        return request.Entity;
    }
}

4. Expose an application service

EntityService wires together MediatR and DTO mapping so consumers can work with transport-friendly types while keeping domain logic in handlers.

public sealed class DocumentService(IMediator mediator)
    : EntityService<Document, DocumentDescriptor, DocumentDto, DocumentDescriptorDto>(
        mediator,
        dto => new DocumentDto { Id = dto.Id, Title = dto.Title },
        dto => new Document { Id = dto.Id, Title = dto.Title },
        descriptor => new DocumentDescriptor { TenantId = descriptor.TenantId });

The service now exposes methods such as AddAsync, UpdateAsync, RemoveAsync, and GetAsync across both entity and DTO representations.

5. Configure caching (optional)

You can plug in the in-memory cache or create your own implementation.

services.AddSingleton<IEntityCache, EntityMemoryCache>();
services.AddSingleton<IEntityCacheInvalidationService, EntityCacheInvalidationService>();

By routing mutations through the provided commands, cache invalidation happens automatically and subscribers can react to EntityNotification events.

Usage tips

  • Use descriptors to capture multi-tenant or contextual filtering concerns. Queries like CountEntitiesQuery<TEntity, TDescriptor> already accept descriptors and flow through your handlers.
  • Combine the package with Vorn.EntityManagement.Generators to reduce boilerplate descriptors and handlers.
  • MediatR pipelines let you add behaviors such as validation, tracing, and audit logging without changing the surface API.

Release artifacts

The README file is bundled with the NuGet package (PackageReadmeFile) so consumers can review philosophy and usage from NuGet.org, Visual Studio, or dotnet list package --include-transitive output.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  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 (1)

Showing the top 1 NuGet packages that depend on Vorn.EntityManagement:

Package Downloads
Vorn.EntityManagement.SignalR.Server

This library provides SignalR entity server base class.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
4.6.0-beta 17 10/5/2025
4.6.0-alpha 20 10/5/2025
4.5.0 42 10/4/2025
4.4.0 230 9/24/2025
4.3.0 234 9/23/2025
4.0.0 245 9/22/2025
4.0.0-rc3 162 9/21/2025
4.0.0-rc2 141 9/21/2025
4.0.0-rc1 149 9/21/2025
4.0.0-gamma 164 9/20/2025
4.0.0-delta 160 9/20/2025
4.0.0-beta 158 9/20/2025
4.0.0-alpha 178 9/20/2025
3.5.0 328 9/17/2025
3.4.0 305 9/17/2025
3.3.0 310 9/17/2025
3.0.0 344 9/16/2025
2.3.0 178 9/8/2025
2.2.1 119 9/6/2025
2.2.0 88 9/6/2025
2.1.1 81 9/6/2025
2.1.0 93 9/6/2025
2.0.0 234 9/1/2025
1.0.0 223 8/27/2025