Domain Model Vs Entity
People often confuse entity with model.
Domain model vs entity. Transformation from domain to persistence entities happens in services which is wrong place to do it. That means that the repository should work with domain entities not persistence entities. I thought entity were more like model objects in the data access infrastructure layer while the domain model is the model in the domain business layer. A model typically represents a real world object that is related to the problem or domain space.
This can happen in child entities within an aggregate if the child entity does not have any special logic because most of the logic is defined in. And that s especially important in domain modeling. An entity is different from a value object primarily due to the fact that an entity has an identity while a value object does not. In ddd the repositories are part of the domain model itself.
Nb regular entity framework code first users will know that it is possible to use the fluent api for mapping between the domain and database structure. It should happen inside the repositories. Guess the term itself is confusing since it. If an entity comes in from the back boundary and fails to serialize or map into a domain model there is a red flag that the data is bad.
These classes known as models have some properties and methods defining their behavior in a particular domain. An entity is a person place thing or event that must be represented in the database. 18 19 and 24. A domain model entity implements behaviors through methods that is it s not an anemic model.
A domain model is a representation of the organization. Of course sometimes you can have entities that do not implement any logic as part of the entity class. But that may be because i haven t seen a domain yet where the model needed anything more complicated. But that is what is happening here.
However these two are quite different. In a particular model i ve typically only had each entity be part of one aggregate. While programming we create classes to represent them. For background reading see the ddd reference book especially pp.
The use of factory classes value objects etc within the domain model pushed the boundaries of what s possible and sensible using the fluent api.