Step 2: Specify the Code Generation Settings

Click Next to go to the Specify the Code Generation Settings page. This page allows you to specify which type of business classes are generated as well as information for generating the names of your business classes. The following screen shot displays the wizard page as well as a UML representation of classes produced by the Business Layer Generator:


Note: The settings on this page and subsequent wizard pages (as well as the size of the wizard form) are persisted in an XML settings file behind the scenes. These settings are automatically restored the next time you run the Business Layer Generator.

Specifying Which Classes to Generate

Each main type of object has a check box next to it which allows you to specify which kind of classes you want to generate:

  • Business Object - The main business object that has methods containing your business logic, representing behavior of real-world entities

  • Entity Object - A strongly typed object that contains business object properties, representing attributes of real-world entities

  • Business Rules Object - Object that validates and enforces business rules

  • Default Values Object - Parameter object that holds default values when creating new data. A default values object is only generated if you specify dynamic default values (as described in the next wizard step).

By default, all four of these objects are selected to be generated for each database object you select on the next page of the wizard. To prevent a particular object from being created, simply uncheck its associated check box. For example, if you have an existing business object for which you want to create an associated entity object (and nothing else). uncheck all the boxes except the Entity Object check box.

Generating Entity Framework Entity Objects

When generating Entity Framework entity objects, select the Entity Framework checkbox. Then, you can check or uncheck the EDMX Generation checkbox, :

  • EDMX Generation Checked - Check this box to use the classic EDMX file to generate business entity classes.

  • EDMX Generation Unchecked - Uncheck this box to use Entity Framework Code First to generate business entity classes.

Understanding the Generated Code

Here is a list of the code that is generated for each type of business class:

Business Class Generated Code
Business Object Class Generates the business object class, with a constructor that contains settings for the TableName, PrimaryKey (or PrimaryKeys) properties, and optionally the PhysicalDbcObjectName and DefaultCommandType properties.
Entity Class Generates the entity object class containing strongly typed properties for all selected database columns. Also adds an Entity property to the main business object class
Business Rules Class Generates the business rules class containing validation methods enforcing business rules. Also adds a Rules property and CreateBusinessRuleObject() method to the main business object class
Default Values Class Generates the default values class containing class-level variables that hold default values for new entities. Also adds a Defaults property and HookSetDefaultValues() method to the main business object class. Note: If you only specify hard-coded default values but do not specify dynamic default values (described in the next step), then the HookSetDefaultValues() method is generated, but a default values object is not generated

Generating Entity, Rule, and Default Value Objects for Existing Business Objects

If you have an existing business object for which you want to generate an entity, rule, or default value object, uncheck the Business Object check box, and select the objects you want to generate. For example, if you want to generate an entity object for an existing business object, uncheck the Business Object check box, make sure the Entity Object check box is selected, and unselect the Business Rules Object and Default Values Object check boxes.

When generating auxiliary objects (entity, rules, defaults), if a reference property already exists on the business object, it is not recreated. When generating a rules object, if the CreateBusinessRuleObject() method already exists on the main business object, it is not recreated. When generating a default values object, if a HookSetDefaultValues() method already exists on the main business object, it is not recreated. If you comment out these existing properties or methods, they will be recreated.

If you check the Unselect All check box, it unselects all objects. This is useful when you are only generating a custom data access class (discussed in a future step).

Table Strip Prefix

The Table Strip Prefix text box allows you to specify a character string prefix that is removed from your database object names before deriving names for your new classes. For example, if you have a three-letter "cus" prefix in your database tables, you can enter cus in the Table Strip Prefix box and these characters will be removed from the default names for your generated classes.

Base Classes

By default, the base class of generated classes are:

  • Business Object - ABusinessObject

  • Entity Object - ABusinessEntity

  • Business Rules Object - ABusinessRule

  • Default Values Object - (no base class)

When you first run the Business Layer Generator, the default base class information is taken from the MM .NET project item templates. You can override these settings by changing the value of the Base Class text boxes. The next time you run the Business Layer Generator, it will recall these settings from its XML configuration file.

Class Prefixes and Suffixes

By default, the Business Layer Generator uses the names of database tables, views and stored procedures as the root name of generated business classes. If you want to automatically add a prefix or suffix to class names, specify it in one or the Class Name Prefix or Class Name Suffix text boxes. A default "Entity" suffix is specified for entity objects, a "Rules" suffix for business rule classes. and a "Defaults" suffix for default value objects.

As an example of how the class naming works, if you are generating a business object from a database table named Inventory, by default, the generator creates a business object called Inventory , an entity class named InventoryEntity, a business rule class named InventoryRules, and a default values object named InventoryDefaults (only if you have specified dynamic default values).

Ultimately, the class root, prefix and suffix are simply defaults. On the next page of the wizard you can manually change the default name of any business class.

Generate Partial Classes

Although all classes generated by the Business Layer Generator are marked as partial classes, when this option is selected, the Business Layer Generator creates partial class source code files for the business object, rule object, and data access classes. You can put custom code in these secondary source code files and it's guaranteed the files will not be overwritten if you regenerate your business layer classes.

See Also:
Step 3: Select Database Items


© (c) 2026 Oak Leaf Enterprises, Inc., 1996-2026 • Updated: 06/27/18
Comment or report problem with topic