Skip to content

2024

Generate Entities for the Database Tables With T4 Templates

With the T4.FileManager we got the missing part to create a code generator based on T4 templates that puts classes into their own files. With that problem solved, we can start our automation project and generate classes for all our database tables, generate the repositories to access the data and finish with integration tests to make sure that our repositories work as expected. Let us start with the entity generator.

Generate Code Into Separate Files With the T4.FileManager

When we generate code with T4, we end up with one single output file per template. That works if we only generate one HTML page or a single class. But when we want to generate multiple classes, the single output file is annoying. We never would let the developers write code that way; therefore, we should not let the automation get away with it either. Let us look at a solution to that problem.

Automate Code Generation With T4 Templates

After exploring the theoretical side of an automation project over the last few weeks, it is now time to get our hands dirty and write some code. There are many options for code generation, but I prefer the T4 templates. We have been using them for years and they are so stable that they form an excellent basis for our automation project.

Consistency Through Standardisation

Last week we elaborated on the different phases we need for a successful automation project. Today we explore the phase of standardisation in more depth.

In our process of Standardisation, Simplification and Automation we are in the phase of Standardisation

A nice side effect of the standardisation is that we get a more consistent output. Instead of the many different ways of doing things, we end up with a single approach and that by itself will reduce the inconsistencies.