Starting a New Module
Where to Put Entities? Layering
The default layout is simple: business entities go directly under EasyAdminBlazor.Demo/Entities/ (demo app) or your own project's Entities/ folder.
For large projects with multiple entry points (API, web front-end, admin back-end), you are free to split into layers:
- Add a shared layer (e.g.
XXX.Application/XXX.Core) for entities, DTOs and common services; - Each host project (API, web, admin) references the shared layer;
- Common approach: the shared layer (
Core/Application) holds entities, DTOs and common services; each host project (API, web front-end, admin back-end) references the shared layer and only handles entry points and UI.
Layering is up to the project scale; the framework does not enforce it.
Catalog-style front-office content (services / products / news / cases) needs no entity: use the Cms extension (
EasyAdminBlazor.Cms) — write a Razor page with[CmsPage]and the admin content management becomes available automatically, see Fast front-office content pages with the Cms extension. This article covers business modules that need real modeled entities (orders, tickets, inventory — actual business data).
1. Create an Entity Class
Inherit from EntityFull:
public class MyNewEntity : EntityFull
{
// Add entity properties
public string Name { get; set; }
public string Description { get; set; }
}
Pro Tip: Use AI to Generate Entity Classes
If you don't want to write entity classes by hand, ask AI (ChatGPT, DeepSeek, Claude, etc.) to do it:
Example prompt:
I need a product table with Name, Price, Stock, and CategoryId (which links to a category table). CategoryId is a foreign key. Use FreeSql entity attributes. The entity class should inherit EntityFull. Add necessary attributes such as Table, Column, DisplayName, and Navigate.
AI-generated code:
[Table(Name = "product")]
public class Product : EntityFull
{
[DisplayName("Product Name")]
[Column(StringLength = 100)]
public string Name { get; set; } = string.Empty;
[DisplayName("Price")]
[Column(Precision = 10, Scale = 2)]
public decimal Price { get; set; }
[DisplayName("Stock")]
public int Stock { get; set; }
[DisplayName("Category ID")]
public long? ClassifyId { get; set; }
[Navigate(nameof(ClassifyId))]
public Classify Classify { get; set; } = default!;
}
Put the code in your project's entity folder, then generate the page in the code generator.
2. Generate Blazor Page
Visit the code generator page at /Admin/CrudGenerator to visually configure and auto-generate CRUD pages.
For detailed instructions, please refer to Code Generation.