Auto Create a new Aggregate

Hi List,

Anyone tried / knows a way todo something like ‘Find or Create’

More or less, this is the expected behaviour :
When a command is sent to a specific Aggregate, (so associated with an AggregateIdentifier) and this Aggregate is not known, it should be created. Thereafter the Command is given to the Aggregate.

Kind regards,


Hi Olger,

I’ve seen it once before, where aggregates were representations of state managed by another system. In that case, they did (pseudo code):

aggregate = repository.load
Catch NotFoundException
aggregate = new Aggregate
repository.add aggregate


Be aware that this is a rather unusual scenario. Normally the query model is used to find out whether an aggregate already exists. But sometimes, breaking the rules is just more efficient. :wink:



Thx, we’ve solved it accordingly and made it explicit of being unusual.