Free C# Entity Generator or C# Class Generator

C# Entity Generator or Class Generator Tool

A few years back, I created a tool “C# Entity Generator”. Though it was created for an older version of visual studio, still it can be useful. I am sharing this tool here so that anyone can download and use it for free. This tool does not require any installation and is a copy paste utility.

C# Entity Generator is a tool which can be used to generate C# Entity Layer classes without writing a single line of code. If we are using three-tier architecture in our applications and need to create entities frequently to map the output of the relational queries, this tool can be very useful. It increases the developer’s productivity especially if the entity contains a large set of properties. Only once would we need to define the data types, their prefixes as per the naming convention guidelines, and their default values. This tool supports the defined variable naming convention and the default value assignment automatically.

Below are the key features of this tool:

  1. Highly configurable.
  2. Creates properties with “get” and “set” methods for the given property name.
  3. Auto defines the underlying variables for the properties using configured naming conventions.
  4. Creates class constructor and assigns the configured default values to the variables.
  5. Creates generic XML documentation for the class and all the properties.
  6. Creates different regions.
  7. Display variables, properties, constructor and full entity data in multiple windows.
  8. Allows to add and remove as many properties as you want.

So, for example, we need to create an entity which can store the EmpId, EmpName, and EmpAddress details in the application’, we just need to put EmpId, EmpName, and EmpAddress in “Enter Property Name” text box and click on the “Add Property” button subsequently. This tool will generate an Employee entity as below:

Entity Generator Demo
Entity Generator Demo

Configuring the Data types, their prefixes, and default values

To manage the configuration values, this tool uses an XML file only. In order to use this tool, firstly we need to define the Data types (which will be available during entity creation), their prefixes as per the naming convention and their default values. This tool uses these defined values when it creates the underlying variables for the given properties. It follows the given naming convention in variable naming. Also, the defined default values are used when it assigns the default values to the variables inside the class constructor. To define the data types follow the below points:

  1. Open the Application “C# Entity Generator”.
  2. Go to menu bar and click on “Settings”.
  3. Select “Manage Data Types & Alias” from the drop-down entry.
  4. Define all the required data types with the corresponding values on the “Manage Data Types And Alias” screen which looks as below.

 

Manage data types
Manage data types

This is a one-time activity only.

Create New Entity or Class

Once we defined the data types, to create a new class follow the below steps:

  1. Open the Application.
  2. Go to menu bar and click on “File” menu.
  3. From the drop-down menu, choose “Create New Class” option or press “Alt + N + F” on the home screen of the Application.
  4. A “Create New Class” screen will appear.
  5. Enter the name of the class
  6. Enter property names, choose their data types, and click on “Add Property” button subsequently.
Create New Class
Create New Class

Finally, this tool will generate the variables, constructor, and the properties in different windows. Also, at the bottom, it will generate a script for the entity which contains all the properties, their underlying variables, and the class constructor. We can simply copy paste this entity into a new class file in visual studio.

Download and Use C# Entity Generator

You can download this tool from the GitHub repository of SQLRelease. Click here to visit the SQLRelease GitHub page. Download the zipped folder “Entity Generator’. Unzip this folder to any location on your machine. The unzipped folder will include an executable file and a required XML file inside a folder named “Entity Generator”. Please keep both these files in the same root folder otherwise it might not work.

Start using it and please share your feedback. Thanks for the download.

FAQ

How much it costs?

It costs you nothing. It is a free tool and can be used for personal or commercial use.

Is installation required

No, this is a copy-paste utility and does not require any installation. You can download it and use it.

From where we can download it

Click here to visit SQLRelease GitHub page and download it.

Please share your input in the comment section of this post.

Rate This
[Total: 3 Average: 5]

Leave a Comment

Your email address will not be published. Required fields are marked *


The reCAPTCHA verification period has expired. Please reload the page.

This site uses Akismet to reduce spam. Learn how your comment data is processed.