Starting a New Module

Where to Put Entities? Layering

The default layout is simple: business entities go directly under EasyAdminBlazor.Test/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.

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!;
}

Copy and paste into your project, then head to the code generator to create the page. Done.

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 代码生成_en-US.md.

That's it!