query-entity

Map command-side events into EF Core-compatible read-model entities with sequence tracking.

4|1|Updated Mar 15, 2026
One-click install
npx skills add https://github.com/FaysilAlshareef/dotnet-ai-kit --skill query-entity-faysilalshareef
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: query-entity
Source: https://github.com/FaysilAlshareef/dotnet-ai-kit/tree/main/skills/microservice/query/query-entity
Command: npx skills add https://github.com/FaysilAlshareef/dotnet-ai-kit --skill query-entity-faysilalshareef

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Design query-side read models with private setters and event-based state updates to project command-side events into read models, ensuring clean separation between write and read models.

Core Features & Use Cases

  • Event<T> envelope: a generic wrapper that carries aggregate id, sequence, user, type, data, timestamp, and version for consistent event propagation.
  • Entity with private setters and EF Core compatibility: constructors from Event<T> for creation, and a private all-parameter constructor for EF Core materialization.
  • Sequence tracking and idempotency: an int Sequence { get; private set; } updated by behavior methods to ensure deterministic projections.
  • Behavior methods with typed data: update methods accept (TData data, int sequence) or full Event<TData> @event as appropriate, always updating Sequence last.
  • Related entities and read-model composition: example OrderItem demonstrates how related data can be modeled.
  • Static factory patterns: some entities use a Create factory for initial computed values.
  • Core patterns and anti-pattern guidance: ensures private setters, no parameterless public constructors, and consistent sequencing.

Quick Start

Create a query-side read model by wiring an Event<T> envelope to a private-setter entity with sequence tracking.

Frequently Asked Questions about query-entity

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I design read models for event sourcing with private setters?

To design read models for event sourcing, map command-side events into query-side entities using private setters and sequence tracking. This ensures clean separation between write and read models while supporting idempotent projections in microservices.

What is the Event<T> envelope pattern in domain-driven design?

The Event<T> envelope pattern is a generic wrapper carrying aggregate id, sequence, user, type, data, timestamp, and version for consistent event propagation. It supports deterministic read-model state updates by passing typed data to behavior methods.

How do I ensure idempotent projections in microservice query models?

Idempotent projections in microservice query models are ensured by tracking an integer sequence updated last by behavior methods. Methods accept typed data and sequence parameters, guaranteeing deterministic state updates and preventing duplicate event processing.

Can I use EF Core with domain-driven design read models that have private setters?

EF Core works with domain-driven design read models by using a private all-parameter constructor for materialization. Entities avoid parameterless public constructors and rely on static factory patterns or Event<T> constructors for initial computed values.

What are the anti-patterns when building query-side read models from event streams?

Anti-patterns when building query-side read models include using parameterless public constructors, exposing public setters, and neglecting sequence tracking. Correct projections require private setters and consistent sequencing to maintain deterministic read-model state.