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:

Highly configurable.

Creates properties with “get” and “set” methods for the given property name.

Auto defines the underlying variables for the properties using configured naming conventions.

Creates class constructor and assigns the configured default values to the variables.

Creates generic XML documentation for the class and all the properties.

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

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:

Open the Application “C# Entity Generator”.

Go to menu bar and click on “Settings”.

Select “Manage Data Types & Alias” from the drop-down entry.

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

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:

Open the Application.

Go to menu bar and click on “File” menu.

From the drop-down menu, choose “Create New Class” option or press “Alt + N + F” on the home screen of the Application.

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.

About Gopal Krishna Ranjan

I am Gopal Krishna Ranjan, having 8 years of industry experience in Software development. I have a head down experience in Database, Data Warehouse, Big Data and cloud technologies and have implemented end to end Database, Data Warehouse, Big Data and Cloud Solutions.
I have extensively worked on SQL Server, Python, Hadoop, Hive, Spark, Azure, Machine Learning, and MSBI (SSAS, SSIS, and SSRS). I also have good experience in windows and web application development using ASP.Net and C#.