Skip to content
christoforosl edited this page May 18, 2015 · 30 revisions

Code Generation of ORM classes.

Before saving objects to the database, one ORM class per database table must exist. Each ORM class must inherit from abstract class ModeloObject. These ORM classes can be generated by the code generation tool of this project. The code generation tool downloads and installs with the Nuget package of the solution

Below are the steps invloved in generating the ORM classes:

  1. Create a .NET "Class Library" project, which will contain: (1) The XML Generation Control File and (2) All generated ORM classes

  2. Create a .NET Test Project to receive Test classes generated by the code generator.

  3. Modify your database to follow these simple conventions:

  4. All tables should have a SINGLE primary key field. If you have composite keys, you can Add a new primary key and make the composite key fields to compose a unique index.

  5. Primary Keys should be either Integer, Long or String fields.

  6. Prepare XML Generation Control File. This file tells the code generator for which tables in the database it should generate ORM classes for. A sample file can be found here: Sample XML for C# generation. The XSD file is at this URL: https://raw.githubusercontent.com/christoforosl/codegen-lib/master/org.codegen.libs/org.codegen.lib/classGenerator.4.xsd

  7. Run code generation The Nuget package of the solution installs the Code Generation EXE file in the tools folder. Alternatively you can download the executable file from the releases folder of this Github project. To run code Generation you simply run the exe codeGenWin4.exe. At the system windowm click "Select" button and then select your XML Generation Control File you created. Then click button "Generate"

After Generation of ORM Classes, the Code Generator presents

  1. Run unit Tests
Clone this wiki locally