A cluster of associated objects that are treated as a unit for the purpose of data changes. External references are restricted to one member of the Aggregate, designated as the root. A set of consistency rules applies within the Aggregate's boundaries.
Questions tagged [aggregateroot]
441 questions
584
votes
11 answers
What's an Aggregate Root?
I'm trying to get my head around how to properly use the repository pattern. The central concept of an Aggregate Root keeps coming up. When searching both the web and Stack Overflow for help with what an aggregate root is, I keep finding discussions…

Dinah
- 52,922
- 30
- 133
- 149
35
votes
1 answer
Repository Pattern with Entity Framework 4.1 and Parent/Child Relationships
I still have some confusion with the Repository Pattern. The primary reason why I want to use this pattern is to avoid calling EF 4.1 specific data access operations from the domain. I'd rather call generic CRUD operations from a IRepository…

jodev
- 749
- 2
- 9
- 13
29
votes
3 answers
Aggregate Root references other aggregate roots
I'm currently working a lot with DDD, and I'm facing a problem when loading/operating on aggregate roots from other aggregate roots.
For each aggregate root in my model, I also have a repository. The repository is responsible for handling…

tschmuck
- 533
- 1
- 5
- 9
26
votes
3 answers
Avoid Unit of Work pattern in domain driven design
I have read this and it makes me think twice...:
"Avoid unit of work pattern. Aggregate roots should define transaction boundaries."
Why should someone avoid the UOW pattern applying domain driven design?

Elisabeth
- 20,496
- 52
- 200
- 321
24
votes
3 answers
Can aggregate root reference another root?
I'm a little bit confused. I just watched
Julie Lerman's Pluralsight video on DDD and here's the confusion I have:
Having a simple online store example with:
Purchase Orders with Items for Suppliers, what's the aggregate root here?
Technically…

Ish Thomas
- 2,270
- 2
- 27
- 57
23
votes
3 answers
How do read-only database views fit into the repository pattern?
Example: Your database has a SQL view named "CustomerOrdersOnHold". This view returns a filtered mix of specific customer and order data fields. You need to fetch data from this view in your application. How does access to such a view fit into the…

300 baud
- 1,672
- 1
- 12
- 18
20
votes
5 answers
DDD: Entity identity before being persisted
In Domain Driven Design, one of the defining characteristic of an Entity is that it has an identity.
Problem:
I am not able to provide a unique identity to Entities on instance creation. This identity is only provided by the repository once the…

Dave New
- 38,496
- 59
- 215
- 394
16
votes
1 answer
Update an entity inside an aggregate
I was reading a similar question on SO: How update an entity inside Aggregate, but I'm still not sure how a user interface should interact with entities inside an aggregate.
Let's say I have a User, with a bunch of Addresses. User is the aggregate…

BenMorel
- 34,448
- 50
- 182
- 322
16
votes
1 answer
Dealing with nested aggregates in DDD
I'm just getting started in DDD, and I'm having some trouble figuring out how to accommodate the relational nature of my data. I have what I believe would be considered my aggregate root, but the aggregate also has an aggregate of its own. Not…

Josh Anderson
- 5,975
- 2
- 35
- 48
16
votes
3 answers
DDD: aggregate root question
Let's say i got 2 entities - Foo and Bar. Foo is an aggregate root and contains Bar. As far as i understand, it should look like this:
public class Foo{
private readonly Bar Bar;
}
I want to provide functionality for users to choose Bars for…

Arnis Lapsa
- 45,880
- 29
- 115
- 195
16
votes
6 answers
DDD - Modifications of child objects within aggregate
I am having some difficulty working out the best way to handle a fairly complex scenario. I've seen quite a few similar questions, but none addressed this scenario to my satisfaction.
An Order (aggregate root) is created with multiple OrderLines…

Cork
- 722
- 6
- 20
15
votes
2 answers
Why are repositories only used for aggregates in Domain-Driven Design?
In DDD, repositories are used to perform serialization and de-serialization of aggregates, e.g. by reading and writing to a database. That way, aggregates can contain purer business logic, and won't be coupled to non-domain-specific persistence…

Hannes Petri
- 864
- 1
- 7
- 15
13
votes
2 answers
How should I enforce relationships and constraints between aggregate roots?
I have a couple questions regarding the relationship between references between two aggregate roots in a DDD model. Refer to the typical Customer/Order model diagrammed below.
First, should references between the actual object implementation of…

Eric Anastas
- 21,675
- 38
- 142
- 236
13
votes
3 answers
DDD navigation to entities inside aggregate root via composite identity
I have an aggregate root Products which contains a list of entities Selection, which in turn contains a list of entities called Features.
The aggregate root Product has an identity of just name
The entity Selection has an identity of name (and its…

morleyc
- 2,169
- 10
- 48
- 108
13
votes
2 answers
DDD: solution for references to a non aggregate root
I have two aggregate roots and two non aggregate root entities:
I know, that the relation D -> B breaks DDD principle.
I heard, that in the most cases the solution is to make the referenced entity a new aggregate root.
But is making B to a new…

frol
- 185
- 8