“Horking

 

HORK Sample: Generating the data model

The HORKTemplateGenerator will generate entity classes to match the tables and columns found in the Downwind database.
The entity classes are output to a path specified at run-time, and will utilize the user-specified namespace.

To show how to use the HORKTemplateGenerator with the Downwind database, lets see a working example in action.

There is a WPF application named WPFWidget that will be using HORK for its data access. WPFWidget uses the primary namespace Company.Apps.WPFWidget.
The VisualStudio project for WPFWidget is located in the path D:\vsProjects\WPFWidget. It has been decided that the namespace for the HORK entities will be Company.Apps.WPFWidget.DataAccessObjects.
To complement the new namespace, the directory D:\vsProjects\WPFWidget\DataAccessObjects has been created.
To create the generated entity classes into the correct directory with the correct namespace, the following values should be used to launch HORKTemplateGenerator:

With these settings, the HORKTemplateGenerator will generate the entity classes right into the VisualStudio project directory with the expected namespace.

In this image we can see the WPFWidget\DataAccessObjects directory with the generated entity classes in the Entities and Loaders directories:
Note that the DataAccessObjects directory also contains the HORKOUT.xml file. This file is an XML representation of the data model which was generated from your database.
The data model file can be used when you want to make changes to the database, but do not want to re-run the HORKTemplateGenerator against a database. For example, after generating your entity classes with HORKTemplateGenerator you may decide to add a column to one table. The database can be changed by running a single ALTER TABLE query, and the HORKOUT.XML file can be edited and have the column added through the XML model.