event-sourcing

Implement event sourcing for .NET domain aggregates with EF Core projections.

Updated Apr 1, 2026
One-click install
npx skills add https://github.com/FoxSilou/ConfigurationClaude --skill event-sourcing-foxsilou
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: event-sourcing
Source: https://github.com/FoxSilou/ConfigurationClaude/tree/main/backend/.claude/skills/event-sourcing
Command: npx skills add https://github.com/FoxSilou/ConfigurationClaude --skill event-sourcing-foxsilou

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill tackles the limitations of state-based persistence in complex domains by enabling event sourcing, providing a complete audit trail, temporal queries, and seamless integration with CQRS for better domain modeling and debugging.

Core Features & Use Cases

  • Domain-Pure Aggregates: Maintains unchanged aggregate logic while replaying events via infrastructure state rebuilders for reconstitution without polluting the domain.
  • Custom SQL Event Store: Implements an append-only store with optimistic concurrency, snapshots, and primitive payloads for SQL Server or PostgreSQL.
  • Projections and Read Models: Builds read-optimized views through inline or async event handlers, feeding the existing Read stack.
  • Use Case: In a game domain like managing 'Partie' aggregates, convert from EF Core persistence to event sourcing to track all state changes as immutable events, enabling conflict resolution in collaborative scenarios.

Quick Start

Scaffold event sourcing for the Partie bounded context by implementing the state rebuilder and repository as described in the references.

Frequently Asked Questions about event-sourcing

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

FAQPage Schema
How do I implement event sourcing for domain aggregates in .NET without polluting the domain logic?

Event sourcing for domain aggregates in .NET is implemented by keeping domain logic pure while using infrastructure state rebuilders to reconstitute aggregate state from immutable events. This approach applies DDD principles to maintain clean bounded contexts.

What is the best way to build an event store with optimistic concurrency in SQL Server or PostgreSQL?

An event store with optimistic concurrency is built as a custom append-only store using primitive payloads for SQL Server or PostgreSQL. This custom SQL event store supports immutable event persistence, conflict resolution, and snapshots for complex state transitions.

How do I create read-optimized projections for a CQRS architecture using EF Core?

Read-optimized projections for CQRS are created using inline or async event handlers that build read models. These projection-based views feed the existing Read stack and integrate with EF Core to provide query-optimized data representations.

When do I need event snapshots for complex aggregate state transitions?

Event snapshots are needed when rebuilding complex aggregate state transitions from a long immutable event stream becomes a performance bottleneck. Snapshots capture aggregate state at specific points, reducing the number of events that must be replayed during reconstitution.

How does event sourcing improve debugging and audit trails in collaborative domain scenarios?

Event sourcing improves debugging and audit trails by persisting all state changes as immutable events, providing a complete temporal history. In collaborative scenarios, this enables conflict resolution through event replay and complex state transition analysis.

Can I convert existing EF Core state-based persistence to event sourcing for bounded contexts?

Yes, you can convert EF Core state-based persistence to event sourcing by implementing a state rebuilder and repository for your bounded contexts. This transition tracks state changes as immutable events while maintaining compatibility with your existing read stack.