Slim your aggregates with Event Sourcing!

This title could be clearer and more informative.Try out Clickbait Shieldfor free (5 uses left this month).

A step-by-step refactoring guide showing how to slim down Event Sourcing aggregates in C#. Starting from a traditional state-heavy ShoppingCart aggregate, the post progressively strips away redundant state (keeping only what business logic invariants actually need), removes the base class by returning events directly from methods, separates state from behavior into an entity and a static service class, and finally models the entity as an immutable record. Each step is illustrated with full C# code. The post also shows how Marten's WriteToAggregate extension simplifies persistence of this slimmed-down design.

19m read timeFrom event-driven.io
Post cover image