create-controller
Installation
SKILL.md
Create API Controller
Create a controller for a given entity in an ASP.NET Core Web API project.
Pre-requisites
- Use Controller-based APIs
- Use System.Text.Json for all JSON data
- The project uses Entity Framework Core 9 — do not install additional packages, the project is already set up.
Steps
-
Create an empty controller with the naming rule:
{EntityName}Controller -
Set up DI and inject Entity Framework context and
ILogger<T>. -
Do not use Entity Class for model binding. Create DTO classes for each CRUD operation instead.
-
Add CRUD REST API methods with required OpenAPI-related annotations.