event-design

Design typed domain event hierarchies for event-sourced .NET systems.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill provides a consistent, production-ready pattern for defining domain events in event-sourced .NET systems, preventing divergent event shapes, fragile serialization, and ordering mistakes that break replay and migration workflows.

Core Features & Use Cases

  • Typed event hierarchy: guidance for an abstract Event base class, a generic Event<TData> wrapper, and immutable IEventData records to keep payloads explicit and versionable.
  • Enum-based event identification: use EventType enum values to drive EF Core discriminators and avoid brittle string identifiers.
  • Sequence and versioning: enforce sequence ordering and a Version field to support schema evolution and safe replays.
  • Practical use case: implement OrderCreated, OrderUpdated, and collection-modification events, convert commands to events via extension methods, and register discriminator mappings in EF Core.

Quick Start

Create an Event<TData> subclass with its IEventData record, add the corresponding EventType enum value, convert your command to the event via an extension method, and register the concrete type in your EF Core discriminator mapping.

Frequently Asked Questions about event-design

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

FAQPage Schema
How do I design domain events for event-sourced microservices in .NET?

To design domain events for event-sourced .NET systems, create an abstract Event base class, use a generic Event<TData> wrapper with immutable IEventData records, and define EventType enum values to drive EF Core discriminators for consistent payload mapping.

How do I map domain events to EF Core using enum discriminators?

Mapping domain events to EF Core requires registering concrete event types in the discriminator configuration using EventType enum values. This enum-driven approach avoids brittle string identifiers and ensures reliable polymorphic serialization.

Why do I need sequence tracking and versioning in event sourcing?

Sequence tracking and versioning are required in event sourcing to enforce sequence ordering and support schema evolution. A Version field ensures safe event replays and prevents migration workflows from breaking when event data records change over time.

What is the best way to convert microservice commands to domain events?

The best way to convert microservice commands to domain events is by using extension methods. This approach creates typed Event<TData> instances from commands, keeping the event payload explicit and ensuring the domain event hierarchy remains versionable.

Can I use string identifiers instead of enums for event discriminators in EF Core?

String identifiers are not recommended for event discriminators in EF Core. Using EventType enum values prevents divergent event shapes and fragile serialization, ensuring robust event replay and migration workflows in event-sourced systems.

How do I handle collection-modification events in an event-sourced domain?

Handling collection-modification events in an event-sourced domain involves creating specific Event<TData> subclasses with their IEventData records. Add corresponding EventType enum values and register the concrete types in EF Core discriminator mappings.