<Nullable>enable</Nullable> configuration setting.All entity classes inherit from EntityBase by default, which defines common properties: Id, CreatedAt, UpdatedAt, and IsDeleted.
The Id property uses Guid type by default, generated on the client using Guid V7.
String properties must define maximum length, unless explicitly unlimited.
Decimal properties must have explicit precision and scale:
decimal(10, 2) is recommendeddecimal(18, 6) is recommended[Column(TypeName = "decimal(10,2)")] public decimal TotalPrice { get; set; }
All enum values must have [Description] attribute.
Use DateTimeOffset for date-time values instead of DateTime to preserve complete time information.
Use DateOnly type for properties that are date-only.
Use TimeOnly type for properties that are time-only.
Helper classes typically end with "Helper" and are usually static classes, unrelated to DI.
Service classes typically end with "Service" and are implementation classes that usually need to be injected via DI.
ManagerBase class, which will be automatically injected via DI. If you don't inherit from it, you need to manually inject.Follow RESTful conventions as the standard.
Controller method names are simple and consistent. For example, to add a user, use AddAsync instead of AddUserAsync:
AddAsyncUpdateAsyncDeleteAsyncGetDetailAsyncFilterAsyncResponses follow HTTP status codes:
When a request succeeds, the frontend can directly retrieve the data.
When a request fails, a unified error format is returned:
{
"title": "",
"status": 500,
"detail": "Unknown error!",
"traceId": "00-d768e1472decd92538cdf0a2120c6a31-a9d7310446ea4a3f-00"
}
Route Definition: Use HTTP verbs, not the Route attribute.
See HTTP Verb Templates.
Model Binding: Use [FromBody] and [FromRoute] to clarify request sources.
See Binding Sources, for example:
// Update user information [HttpPut("{id}")] public async Task<ActionResult<TEntity?>> UpdateAsync([FromRoute] Guid id, TUpdate form)
Return Type: Use ActionResult<T> or specific types as return types.
Problem(), for example:// If error, use Problem to return content return Problem("Unknown error!", title: "Business Error");
NotFound(), for example:// If not found, return 404 return NotFound("Username or password does not exist");