Generate a full ASP.NET Core API resource — controller, service, and repository with CRUD operations — from a single command.
- One command generates the controller, service, and repository (plus interfaces when requested) for a given model.
- Basic CRUD operations: GetAll, GetById, Create, Update, Delete.
- Repository methods are generated as
NotImplementedExceptionstubs for the developer to fill in with the real data access. - Detects an existing model class; if the model is missing, it signals you and offers to create a stub.
- Auto-detects the root namespace from the
.csprojand places files in conventional folders. - Optional dependency-injection registration in
Program.cs.
- Open a .NET API project folder in VS Code.
- Run the command ".NET API Scaffold: Generate Resource" from the Command Palette (
Cmd+Shift+P) or the Explorer context menu. - Choose With interfaces or Without interfaces.
- Enter the model name (e.g.
Product). - If the model doesn't exist, confirm creating a stub model.
- Optionally confirm registering the generated services in
Program.cs.
For a Product model with interfaces enabled:
Controllers/ProductsController.cs
Services/IProductService.cs
Services/ProductService.cs
Repositories/IProductRepository.cs
Repositories/ProductRepository.cs
Models/Product.cs (only if the model did not already exist)
| Setting | Default | Description |
|---|---|---|
dotnetApiScaffold.folders.controllers |
Controllers |
Folder for controllers |
dotnetApiScaffold.folders.services |
Services |
Folder for services |
dotnetApiScaffold.folders.repositories |
Repositories |
Folder for repositories |
dotnetApiScaffold.folders.models |
Models |
Folder for models |
dotnetApiScaffold.defaultWithInterfaces |
true |
Default answer for the interfaces prompt |
dotnetApiScaffold.rootNamespace |
"" |
Override the root namespace (empty = auto-detect from .csproj) |
- VS Code 1.85 or later.
- An ASP.NET Core (.NET 6+) project.
npm install
npm run compile # build
npm run test:unit # unit tests (mocha)
npm run test:integration # integration test (requires VS Code download)
npm run package # produce .vsix
Prebuilt .vsix packages are attached to every GitHub Release. The rolling latest release always points at the newest build; the workflow run page also exposes the artifact.