DDD: Entity identity before being persisted

后端 未结 5 2147
面向向阳花
面向向阳花 2020-12-25 07:58

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 uni

5条回答
  •  心在旅途
    2020-12-25 08:36

    I cannot begin to use Guid values at this point.

    Yes you can and that would be an alternative. Guids would not be your database primary keys but rather would be used at the domain model level. In this approach you could even have two separate models - a persistence model with ints as primary keys and guids as attributes and another model, the domain model, where guids play the role of identifiers.

    This way your domain objects can get their identities once created and persistence is just one of minor business concerns.

    The other option known to me is the one you described.

提交回复
热议问题