DEFC.Util.RepoGen
If youβve ever built a .NET application that uses stored procedures, youβve probably written a lot of repetitive repository code. While clean architecture and the repository pattern are great for maintainability, they come with a cost β boilerplate.
Thatβs why I built RepoGen β a NuGet CLI tool that helps .NET developers automatically generate repository classes, structure folders, and map stored procedures with just a few commands.
π§© What is RepoGen?
DEFC.Util.RepoGen is a .NET CLI and NuGet tool that automates the implementation of the Repository
and Unit of Work patterns using SQL Server stored procedures. It simplifies the generation of clean,
scalable, and maintainable architecture in .NET applications, while promoting strong separation of concerns.
π§ Beta Version Notice
π¬ This is a Beta Release
DEFC.Util.RepoGen
is currently in beta and under active testing. While it is functional and ready for
practical use, we are still refining and improving the tool based on user feedback.
We invite developers and teams to test the tool in real-world scenarios and help us identify bugs, edge cases, or areas for improvement.
Your feedback is valuable and will directly contribute to shaping the final stable release.
π οΈ Key Features
- β Automatic Repository Generation β Generates repository classes mapped to SQL Server stored procedures.
- β
Unit of Work Integration β Creates a
UnitOfWork
class to manage transactions across repositories. - β Stored Procedure Mapping β Automates method creation inside repositories that correspond to stored procedures.
- β CRUD Generator β Generates full CRUD (Create, Read, Update, Delete) logic and models for SQL tables.
- β Clean Architecture Support β Supports multiple folder structures: Clean, Layered, Hexagonal, or Custom.
- β Batch Command Execution β Run multiple operations from a JSON batch script.
- β Dynamic DTO & Model Generation β Generates Data Transfer Objects and domain models from stored procedures or tables.
- β Endpoint Creation β Auto-generates RESTful controller endpoints (e.g., POST, GET, PUT, DELETE) alongside SP and CRUD mappings.
- β Offline & Secure β Operates fully offline with no external calls or telemetry.
π Prerequisites
Install required EF Core dependencies:
dotnet add package Microsoft.EntityFrameworkCore
dotnet add package Microsoft.EntityFrameworkCore.SqlServer
dotnet add package Microsoft.Data.SqlClient
π¦ Installation
Install the NuGet package:
dotnet new tool-manifest
dotnet tool install --local DEFC.Util.RepoGen --version 1.0.0-beta
π Quick Start
- Initialize:
dotnet tool run RepoGen initial
dotnet tool run RepoGen initial
- Configure RepoGen.json:
{
"Config": {
"DBConfig": {
"SchemaID": "1",
"DBContextName": "YOUR_DBCONTEXTNAME_HERE",
"ConnectionString": "Server=SERVER_NAME;Database=DATABASE_NAME;User Id=USER_NAME;Password=PASSWORD;TrustServerCertificate=True"
},
"AppConfig": {
"Namespace": "YOUR_NAMESPACE_HERE",
"FoldersStructureModel": "MODEL_1",
"LoggerCode": "101",
"Suffixes": {
"Model": "Models", // Suffix for domain or entity classes
"DTO": "Dtos" // Suffix for data transfer objects
}
}
}
}
- Generate Folder Structure:
dotnet tool run RepoGen structure set
- Test DB Connection:
dotnet tool run RepoGen test db-connection
dotnet tool run RepoGen structure test
- Generate CRUD for a Table:
dotnet tool run RepoGen crud --tbl <YourTableName> --service <YourServiceName> --controller <YourControllerName>
dotnet tool run RepoGen crud --tbl <YourTableName> --service <YourServiceName>
- Stored Procedure Mapping
1- Map a stored procedure to a repository:
dotnet tool run RepoGen map --sp <YourStoredProcedureName> --repo <YourRepoName> --controller <ControllerName> --endpoint <EndpointName> --<Method>
dotnet tool run RepoGen map --sp <YourStoredProcedureName> --repo <YourRepoName>
2- Remap a stored procedure to a repository with controller endpoint:
dotnet tool run RepoGen re-map --sp <YourStoredProcedureName> --repo <YourRepoName> --controller <ControllerName> --endpoint <EndpointName> --<Method>
3- Remove a mapped stored procedure:
dotnet tool run RepoGen remove --sp <YourStoredProcedureName> --repo <YourRepoName>
π Architecture Support
- π§± MODEL_1: Clean Architecture (default)
- π§± MODEL_2: Layered Architecture
- π§± MODEL_3: Hexagonal (Ports & Adapters)
- π§± MODEL_CUSTOM: Fully configurable layout via custom_model.json
π Documentation
Full guides, step-by-step examples, and command references are available in the π Wiki
π¦ Try It Yourself
RepoGen is available now as a NuGet package. If you're working on a .NET project and want to save time while keeping your code clean, give RepoGen a try!
You can find RepoGen on NuGet.
You can find RepoGen sample on GitHub.
π Related Packages
π License
Licensed under the Elastic License 2.0.
See full license details here.
π Issues & Feedback
Found a bug or want to contribute?
π¬ Open an issue
π More About RepoGen
π Thank you for supporting the development of DEFC.Util.RepoGen. Letβs build clean, maintainable .NET applications together!
Top comments (0)