Practical Domain-Driven Design with EF Core
summary
Refactors a legacy .NET 5 API using EF Core 5 and MediatR to turn an anemic model into a rich domain: parameterized constructors with private EF ctor enforce invariants, behavior moves into entities (customer.AddSubscription, product.CalculateExpiry), and cross-entity logic becomes a domain service. Tests run as refactors happen and integration tests pass after changes. Domain events publish via a SaveChanges interceptor to MediatR, value objects map with owned types, and patterns shown include specification/extension queries and strongly typed entity IDs.
AI-written summary · about
chapters (21)
- 0:00Intro
- 1:14What is Domain-Driven Design?
- 1:38What is Domain Model? An object model of the domain that incorporates both behavior and data.' - Martin Fowler
- 2:44Bounded Contexts • A defined part of software where particular terms, definitions and rules apply in a consistent way Clear boundaries between different parts of the system
- 4:01Inside the Core Domain
- 5:49Sample Domain
- 20:56Extract Methods
- 21:16Avoid Public Setters
- 21:40Encapsulate Behavior in Domain Model
- 32:39Encapsulate Behavior in Domain Service
- 32:51Double Dispatch
- 42:03Domain Events
- 46:42From Primitive Obsession to Value Objects
- 47:50Where is the Repository?
- 48:55Can the Unit of Work help us?
- 49:24Embrace the DbContext
- 50:31Specification: Current Query
- 51:28Specification: Base Classes
- 51:53Specification: Concrete Sample
- 53:12Specification: Extension Methods
- 53:56Base Entity ID
related talks
55mPractical Domain-Driven Design with EF Core
59mMapping DDD Domain Models with EF Core 2.1
46mMapping Well-Designed Domain Models with EF Core 2.1
01h 10mModern Data Applications with Entity Framework 7
01h 00mGetting the best out of Entity Framework Core
47mEF Core 6: Working on the Bucket List
44mEF Core database model first - take it to the next level with Power Tools CLI
46mEntity Framework Core 2.1 – what’s new?
