After Generating Database Objects from an UML Model you are desperately in need of a data access layer (DAL) and a business logic layer (BLL). Today we are going to generate the famous Business Entities.

After executing that funny sql-script we generated from UML previously, you are the proud owner of a database. Since I am a great fan of MyGeneration we will use a similar approach and scrape the meta model from the database.

To be able to do so, the code generator needs some input. First, it has to know which tables must be read (filter) and where to find the tables (database) to extract meta data from.

image

At this point the generator has enough information to read the data model and generate code. The list of tables are traversed and classes are created. Within each table the meta data of its columns are extracted.

image

Since we – at this moment – are not able to automagically convert data types, we also need a support routine for conversion of database type to its C#.NET equivalent. This is done by append some script to the template.

image

Finally, using this template, the following code is generated from the selected data model.