GenXCleanArchTemplate.WebAPI
1.0.7
See the version list below for details.
dotnet add package GenXCleanArchTemplate.WebAPI --version 1.0.7
NuGet\Install-Package GenXCleanArchTemplate.WebAPI -Version 1.0.7
<PackageReference Include="GenXCleanArchTemplate.WebAPI" Version="1.0.7" />
<PackageVersion Include="GenXCleanArchTemplate.WebAPI" Version="1.0.7" />
<PackageReference Include="GenXCleanArchTemplate.WebAPI" />
paket add GenXCleanArchTemplate.WebAPI --version 1.0.7
#r "nuget: GenXCleanArchTemplate.WebAPI, 1.0.7"
#:package GenXCleanArchTemplate.WebAPI@1.0.7
#addin nuget:?package=GenXCleanArchTemplate.WebAPI&version=1.0.7
#tool nuget:?package=GenXCleanArchTemplate.WebAPI&version=1.0.7
GenX Clean Architecture Template
Creating a new project
To create a new project using the template, run the following command:
dotnet new genx-cleanarch -n NewProjectName
Project Structure
For each entity in your database model, create the following structure:
|- Domain
|- Entities
-- <entity>.cs
|- Infrastructure
|- Config
-- <entity>Config.cs
|- Repositories
-- <entity>Repository.cs
|- Interfaces
-- I<entity>Repository.cs
|- Application
|- Services
-- <entity>Service.cs
|- Interfaces
-- I<entity>Service.cs
|- WebAPI
|- Controllers
-- <entity>Controller.cs
Configuring each entity in the project
1. Update the AppDbContext.cs file:
Location: Infrastructure/Data/AppDbContext.cs
Add the following configuration for each entity:
public DbSet<entity> <entity> { get; set; }
2. Configure in the Program.cs file:
Location: WebAPI/Program.cs
Add the following services for each entity:
builder.Services.AddScoped<I<entity>Repository, <entity>Repository>();
builder.Services.AddScoped<I<entity>Service, <entity>Service>();
Creating a MySQL Database
Follow the steps below to set up the MySQL database:
- Access the MySQL terminal:
mysql -u root -p
- Create the database and user:
CREATE DATABASE `GenXCleanArchTemplate-db` CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'GenXCleanArchTemplate-user'@'localhost' IDENTIFIED BY 'GenXCleanArchTemplate-password';
GRANT ALL PRIVILEGES ON `GenXCleanArchTemplate-db`.* TO 'GenXCleanArchTemplate-user'@'localhost';
FLUSH PRIVILEGES;
exit;
Creating Entity Framework (EF) Migrations Scripts
- Install the EF Core CLI tool (if not installed yet):
dotnet tool install --global dotnet-ef
- Create the initial migration:
dotnet ef migrations add initial-migration --project GenXCleanArchTemplate.Infrastructure --startup-project GenXCleanArchTemplate.WebAPI
- Update the database:
dotnet ef database update --project GenXCleanArchTemplate.Infrastructure --startup-project GenXCleanArchTemplate.WebAPI
Running the WebAPI
You can run the WebAPI in two ways:
1. From the terminal:
dotnet run --project GenXCleanArchTemplate.WebAPI
2. In debug mode:
If using Visual Studio Code, press F5 to start in Debug mode.
The GenX Clean Architecture template is now configured and ready to use. š
PT-BR
Criando um novo projeto
Para criar um novo projeto utilizando o template, execute o seguinte comando:
dotnet new genx-cleanarch -n NewProjectName
Estrutura do Projeto
Para cada entidade do seu modelo de banco de dados, crie a seguinte estrutura:
|- Domain
|- Entities
-- <entity>.cs
|- Infrastructure
|- Config
-- <entity>Config.cs
|- Repositories
-- <entity>Repository.cs
|- Interfaces
-- I<entity>Repository.cs
|- Application
|- Services
-- <entity>Service.cs
|- Interfaces
-- I<entity>Service.cs
|- WebAPI
|- Controllers
-- <entity>Controller.cs
Configuração para cada entidade no projeto
1. Atualize o arquivo AppDbContext.cs:
Local: Infrastructure/Data/AppDbContext.cs
Adicione a seguinte configuração para cada entidade:
public DbSet<entity> <entity> { get; set; }
2. Configure no arquivo Program.cs:
Local: WebAPI/Program.cs
Adicione os seguintes serviƧos para cada entidade:
builder.Services.AddScoped<I<entity>Repository, <entity>Repository>();
builder.Services.AddScoped<I<entity>Service, <entity>Service>();
Criando um banco de dados MySQL
Siga os passos abaixo para configurar o banco de dados MySQL:
- Acesse o terminal do MySQL:
mysql -u root -p
- Crie o banco de dados e o usuƔrio:
CREATE DATABASE `GenXCleanArchTemplate-db` CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'GenXCleanArchTemplate-user'@'localhost' IDENTIFIED BY 'GenXCleanArchTemplate-password';
GRANT ALL PRIVILEGES ON `GenXCleanArchTemplate-db`.* TO 'GenXCleanArchTemplate-user'@'localhost';
FLUSH PRIVILEGES;
exit;
Criando scripts de migração do Entity Framework (EF)
- Instale a ferramenta CLI do EF Core (caso ainda não tenha instalado):
dotnet tool install --global dotnet-ef
- Gere a migração inicial:
dotnet ef migrations add initial-migration --project GenXCleanArchTemplate.Infrastructure --startup-project GenXCleanArchTemplate.WebAPI
- Atualize o banco de dados:
dotnet ef database update --project GenXCleanArchTemplate.Infrastructure --startup-project GenXCleanArchTemplate.WebAPI
Executando a WebAPI
VocĆŖ pode executar a WebAPI de duas formas:
1. Pelo terminal:
dotnet run --project GenXCleanArchTemplate.WebAPI
2. No modo de depuração:
Se estiver usando o Visual Studio Code, pressione F5 para iniciar no modo Debug.
Pronto! O template GenX Clean Architecture estĆ” configurado e pronto para uso. š
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- GenXCleanArchTemplate.Application (>= 1.0.0)
- GenXCleanArchTemplate.Domain (>= 1.0.0)
- GenXCleanArchTemplate.Infrastructure (>= 1.0.0)
- Microsoft.AspNetCore.Authentication.JwtBearer (>= 8.0.10)
- Microsoft.AspNetCore.OpenApi (>= 8.0.10)
- Pomelo.EntityFrameworkCore.MySql (>= 8.0.2)
- Swashbuckle.AspNetCore (>= 6.9.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.13 | 178 | 10/5/2025 |
| 1.0.12 | 180 | 10/5/2025 |
| 1.0.11 | 183 | 10/5/2025 |
| 1.0.10 | 162 | 12/24/2024 |
| 1.0.9 | 167 | 12/14/2024 |
| 1.0.8 | 142 | 12/2/2024 |
| 1.0.7 | 155 | 11/20/2024 |
| 1.0.6 | 151 | 11/20/2024 |
| 1.0.5 | 158 | 11/20/2024 |
| 1.0.4 | 148 | 11/20/2024 |
| 1.0.3 | 151 | 11/20/2024 |
| 1.0.2 | 150 | 11/17/2024 |
| 1.0.1 | 163 | 11/17/2024 |
| 1.0.0 | 157 | 11/16/2024 |