The model-driven code generation process is really simple.

You create a model, for example using UML. Next, you feed a hungry generator with your model in a format it can digest. That could be XMI.

model-driven code generation process

The model-driven generator (MDG) transforms your model into code using a template of some kind. Here it outputs C# code that can be compiled into an assembly using a c#-compiler. You also will need some framework or platform to run your code.

The hard part is creating a good model.