In this article, I will list some CRUD page generation/code generation tools for .NET and then we will explore the ABP Suite that empowers .NET developers to generate CRUD pages and is distinguished from other tools by its features and user-friendly UI.
Code/CRUD Page Generation Tools
There are some CRUD page generation tools that you may already know as listed below:
- ABP Suite (supports plenty of UI options - MVC, Blazor WASM, Blazor Server, Angular, etc. - also supports mobile options)
- Radzen (only supports Blazor & Angular)
- CodeSmith Generator
- Also, there are a bunch of open-source code generation tools with limited options...
Among these code-generation tools, ABP Suite is in a special place in my opinion. It's not just related to working on it, but also its capabilities, and what it's providing is really noteworthy. Therefore, in the following section, I want to mention what ABP Suite is and some of its capabilities.
If you are looking for a code generation tool that's gonna speed up your business, I highly recommend you to check the ABP Commercial, try its demo, and see all of its capabilities.
ABP Suite
ABP Commercial is a complete web development platform built on open-source ABP Framework.
ABP Suite is a complementary tool to ABP Commercial and allows you to build web pages in a matter of minutes.
ABP Suite allows you to easily create CRUD pages. You just need to define your entity and its properties and let the rest go to ABP Suite for you! ABP Suite generates all the necessary code for your CRUD page in a few seconds. It supports Angular, MVC, and Blazor (both Blazor Server and Blazor WASM) UIs.
Creating A New Solution
You can create a new solution from the ABP Suite UI, by selecting one of the startup templates provided by ABP Commercial.
You can select a template type, project name, output folder where the project will be created, UI Framework as your front-end, mobile option (React Native or MAUI), database provider, database management system (if the database provider is Entity Framework Core), connection string, theme and more...
See the documentation for all other options and their descriptions.
Generating CRUD Pages
When you add an existing project or create a new one, the project will be listed in the "Open Recent" section. Then, you can select the project, and start generating CRUD pages.
ABP Suite provides the following features for code generation:
- Creating One-To-Many & Many-To-Many Relationships
- Generating CRUD Pages From an Existing Database Table
- Customizable Code Support (allows you to customize the generated code to your needs)
- Creating Master-Detail (Master/Child) Relationship
Let's deep-dive into these features and see them one by one.
Creating One-to-Many & Many-to-Many Relationship
ABP Suite allows you to create one-to-many and many-to-many relationships. You only need to click the Navigations tab and click either the Add navigation connection (n-n) button to establish a many-to-many relationship or the Add navigation property (1-n) button to establish a one-to-many relationship.
When you establish a many-to-many relationship, ABP Suite will do the rest for you and generate a join entity (also join table in the database) and all of the required codes by following DDD principles.
For example, if you establish a many-to-many relationship between the Book and Category entities, then ABP Suite creates the related join table named "BookCategories":
Also, if you selected the Create User Interface option, it creates the related web page for you as in the following figure:
It's the same if you establish a one-to-many relationship. ABP Suite adds the related navigation property to the related entity and generates all related codes for you, including export to excel support, customizable code support, web pages, unit tests, advanced filters, and more according to the enabled options...
Generating CRUD Pages From an Existing Database Table
If you have an existing database table, you can generate the entities using ABP Suite and create a CRUD page based on those entities.
You first need to create an application from ABP Suite or add an existing project. Then, after opening the project in ABP Suite, you can scroll down to the bottom and click the Load Entity From Database button:
A modal will be opened, and then you can specify the connection string for your database, test the connection, and click the Connect button to allow ABP Suite to list all tables for you:
Then, you can uncheck the related properties such as Id, ConcurrencyStamp and others, you can click the "Ok" button.
After that, ABP Suite will auto-fill all related entity metadata for you in the UI, and then you can revise them and by clicking the "Save and generate" button, you can generate the related entity within seconds.
Here is the video that summarizes the process:
Customizable Code Support
ABP Suite allows you to customize the generated code blocks and preserve your custom code changes in the next CRUD Page Generation. It specifies hook points to allow adding custom code blocks. Then, the code written by you to these hook points will be respected and will not be overridden in the next CRUD Page Generation.
To enable custom code support, you should check the Customizable code option in the CRUD Page Generation page (it's selected by default). When you enable the custom code support, you will see some hook points in your application on both the backend and UI side.
On the C# side (backend), you'll be seeing some abstract classes and classes that derive from them (for entities, application services, interfaces, domain services, and so on ...) according to the template that you have created.
You can write your custom code in those classes (with the *.Extended.cs
extension) and next time when you need to re-generate the entity, your custom code will not be overridden (only the base abstract classes will be re-generated and your changes on Suite will be respected).
Let me share an example from the documentation:
IBookRepository.Extended.cs |
EfCoreBookRepository.Extended.cs |
---|---|
defining a new method in the IBookRepository interface |
implementing the method in the EfCoreBookRepository class |
As can be seen in the example above, if you write your custom code in the *.Extended.cs
files, then in the next generation, all of the code written by you, will be preserved and not overridden. Thus, you have an option to customize the generated code, by overriding the related methods and also you can extend the generated codes according to your needs.
For the UI side, ABP Suite provides convenient comment placeholders within pages for MVC, Blazor, and Angular UIs.
For example, in the screenshot above, you can see the example placeholders (hook-points) for MVC/Razor Pages, where you can write your custom code and make customizations on the page.
In addition to these hook points, you can also add new custom hook points and change their places. You can check this documentation to see how it can be done.
For all of the customization tips and directives, please refer to the documentation: https://docs.abp.io/en/commercial/latest/abp-suite/customizing-the-generated-code
Creating Master-Detail (Master/Child) Relationship
ABP Suite allows you to create a master-detail relationship with a few clicks. It generates the necessary code for the master and detail tables, including the foreign key relationship between the two tables.
To establish a master-detail relationship, you can apply the following steps:
- Creating the master entity
- Creating the child entity and associating it with a master entity
For example, let's assume you want to establish a master/child relationship between the Order and OrderDetail entities, in that case, you first need to create the Order entity and then you can create the OrderDetail entity and specify its entity type as Child like in the following screenshot:
Then, after the code generation, if you run the application, you will see an output as follows:
As you can see, you have a parent data grid and child data-grids for each order record. You can create your orders from this page and add order lines for each order. So, you can manage all of the orders and order lines from a central point and filter them, or export all of the orders to an Excel file and more...
If you want a quick overview of these features (customizable code support, establishing one-to-many and many-to-many relationships, creating master/detail relationships, and more), you can check the ABP Suite Webinar 2024 Demo video from YouTube.
If you are looking for complete instructions and descriptions for ABP Suite, you can check the ABP Suite docs and webinars organized by the core ABP Framework team:
Other Features
ABP Suite's features are not limited to the features described in the previous sections. It provides so many features, that it makes it impossible to mention all of them, but here are some of the other features:
- Updating NPM & NuGet Packages Automatically
- Editing / Customizing Templates
- Accessing the Source Code Of Modules
- ...
Conclusion
In conclusion, ABP Suite is a game-changer in the realm of application development. Its modular design (comes from ABP Framework), powerful code generation, and support for modern frontend frameworks make it a go-to choice for developers looking to build scalable and feature-rich applications. Whether you are working on a small project or a large enterprise application, ABP Suite provides the tools you need to succeed in your development endeavors.
Top comments (0)