Starting a New Module
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!