GenXCleanArchTemplate.WebAPI 1.0.7

There is a newer version of this package available.
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
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="GenXCleanArchTemplate.WebAPI" Version="1.0.7" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="GenXCleanArchTemplate.WebAPI" Version="1.0.7" />
                    
Directory.Packages.props
<PackageReference Include="GenXCleanArchTemplate.WebAPI" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add GenXCleanArchTemplate.WebAPI --version 1.0.7
                    
#r "nuget: GenXCleanArchTemplate.WebAPI, 1.0.7"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package GenXCleanArchTemplate.WebAPI@1.0.7
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=GenXCleanArchTemplate.WebAPI&version=1.0.7
                    
Install as a Cake Addin
#tool nuget:?package=GenXCleanArchTemplate.WebAPI&version=1.0.7
                    
Install as a Cake Tool

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:

  1. Access the MySQL terminal:
mysql -u root -p
  1. 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

  1. Install the EF Core CLI tool (if not installed yet):
dotnet tool install --global dotnet-ef
  1. Create the initial migration:
dotnet ef migrations add initial-migration --project GenXCleanArchTemplate.Infrastructure --startup-project GenXCleanArchTemplate.WebAPI
  1. 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:

  1. Acesse o terminal do MySQL:
mysql -u root -p
  1. 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)

  1. Instale a ferramenta CLI do EF Core (caso ainda não tenha instalado):
dotnet tool install --global dotnet-ef
  1. Gere a migração inicial:
dotnet ef migrations add initial-migration --project GenXCleanArchTemplate.Infrastructure --startup-project GenXCleanArchTemplate.WebAPI
  1. 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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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