Code Generation

The designed CQRS model can be turned into .NET source code (either VB.Net or C#) by selecting the "Code Generation" menu item in the DSL designer (in the Visual Studio IDE).


Since the choice of programming language is (usually) a per-project setting this is set in the CQRS model properties.

The code generator generates a separate interface and class for each aggregate, event, projection etc. in the model. The interface is generated so that you can create mock objects in unit tests or create WCF interfaces etc. The class is implemented as a partial class so that you can extend the class and any changes you make will not be overwritten if the model code is regenerated.


The model name is used to create the namespace within which the other classes and interfaces all reside. This is required because it is not unusual to have two domains (implemented as separate models) that contain aggregate identifiers with the same name.

Aggregate identifier

The key type is used to create an interface and class that inherit from CQRSAzure.EventSourcing.IAggregationIdentifier(Of TKey) so that our resulting code is type safe.

Last edited Oct 30, 2015 at 5:21 PM by Merrion, version 2