@shivay_18/dotnet-crud-generator
v1.0.0
Published
CLI generator for production-ready .NET 8 Entity Framework Core Web API controllers, services, repositories, DTOs, and entity configurations
Maintainers
Readme
.NET 8 Entity Framework CRUD Generator (dotnet-crud-generator)
CLI tool to automatically generate complete, production-ready .NET 8 Entity Framework Core Web API controllers, services, repositories, DTOs, and entity configurations.
Key Features
- ⚡ Zero Runtime Dependencies: Generates pure C# .NET 8 and Entity Framework Core code. The generator package leaves no runtime dependency behind.
- 🏗️ Clean Architecture Best Practices: Generates separate layers: Entities, DTOs (Read, Create, Update, QueryParameters, PagedResult), EF Core Configurations (
IEntityTypeConfiguration<T>), Repository pattern with LINQ queries, Service layer, and Web API Controllers. - 🔍 Built-in LINQ Paging, Searching, Filtering & Sorting: Supports pagination, case-insensitive multi-field search, dynamic field filters, and field sorting.
- 🛡️ Validation & RFC 7807 Error Handling: DataAnnotations validation attributes (
[Required],[StringLength],[Range],[EmailAddress]) and standard Http status responses. - ⚙️ Seamless Angular Integration: Contracts (DTOs, PagedResult, query string parameters) directly pair with
angular-crud-generator.
Installation / Usage
Run via npx without installing globally:
# Generate using a configuration file
npx dotnet-crud generate --config ./crud.config.json
# Generate using CLI arguments directly
npx dotnet-crud generate Product --fields name:string:required,price:decimal:min=0,isAvailable:boolean --primaryKey id:guid --namespace MyApp.Api --output ./src/MyApp.ApiGenerated Files
For an entity Product, the CLI generates:
src/MyApp.Api/
├── Entities/
│ └── Product.cs
├── DTOs/
│ └── ProductDto.cs (Contains ProductDto, CreateProductDto, UpdateProductDto, ProductQueryParameters, PagedResultDto)
├── Data/
│ └── Configurations/
│ └── ProductConfiguration.cs
├── Repositories/
│ └── ProductRepository.cs (Contains IProductRepository and ProductRepository)
├── Services/
│ └── ProductService.cs (Contains IProductService and ProductService)
└── Controllers/
└── ProductsController.csCLI Options
| Flag | Shortcut | Description | Default |
| --- | --- | --- | --- |
| --config | -c | Path to crud.config.json | null |
| --fields | -f | Comma-separated fields format name:type:validators | [] |
| --primaryKey | -pk | Primary key definition (e.g. id:guid or id:int) | id:guid |
| --namespace | -ns | C# Namespace for generated classes | App.Api |
| --output | -o | Target directory for generated C# files | Current Working Directory |
| --help | -h | Display CLI usage help | |
