c# – DDD Final consistency between aggregates


Situation: there are the following units:

  • Car
  • Engine
  • Wheels
  • Body
  • The model of car
  • Engine model
  • Wheel model
  • Body model

Each unit has its own identifier. Inside the car are engine, wheel and body identifiers. Each vehicle unit contains the identifier of the corresponding model.

There is a rule: when installing the engine, wheels and body in a car, their models must be compatible with the car model. That is, some parameters of the models of the subsidiary equipment must match the corresponding parameters of the machine model.

Let's say an engine is already installed in the car. I decided to change the engine model. The engine unit has changed and has been saved to the database. But the engine model must be compatible with the car model. It turns out there should be a final consistency ( Eventual Consistency ) between the Machine and Engine units.

Question: How to correctly implement the resolution of the conflict of discrepancy between the new engine model and the car model on which the engine has already been installed?

PS It is easiest to carry out such checks in advance in the application service before changing the unit model. However, there should be no domain model logic in application services.


In a well-known subject environment, I would take the simplest path. The engine knows that it can be used in the car and, upon its own attempt to save, will re-save (revalidate) the car.

In theory, you need to make some kind of event service that everyone interested is subscribing to, but see for yourself, the implementation will not be very simple and rather unclear, especially in the case of cyclic events that will start generating each other.

Scroll to Top