AHutak.OnionArchitecture.AspNet 1.0.1

There is a newer version of this package available.
See the version list below for details.
dotnet new install AHutak.OnionArchitecture.AspNet::1.0.1                
This package contains a .NET Template Package you can call from the shell/command line.

icon ASP.NET Onion Architecture Solution Template

.NET CodeQL Nuget Nuget

Template Description

This is a solution template for creating an ASP.NET Web API application following the Onion Architecture. You can create a new solution based on this template by installing and running the associated NuGet package.

The template contains:

  • Domain, Application, Persistence, Infrastructure, API projects,
  • MS SQL and MongoDB persistence layer implementations wich user can choose during solution creation,
  • Unit tests and Component tests template projects,
  • WebAPI project with minimal API's and optionally standard controllers

Getting Started

Installing the template

To install this template on your system run the following command with the latest package version

dotnet new --install AHutak.OnionArchitecture.AspNet::<latest version>

You should see the message as shown below which indicates successfull installation

image

After that you have several options, to use it either from Visual Studio 2022 or from command-line.

From Visual Studio 2022:

image

image

From command-line:

dotnet new oa-sln-aspnet -n Your-Project-Name

To view other available command-line solution parameters please run

dotnet new oa-sln-aspnet --help

At the moment this template supports two persistence layer implementations:

  • MS SQL with EF Core
  • MongoDB.

You can select one of them during solution creation.

Launching the solution

The next step to launch the newly created solution is updating the appsettings json files in API project.
You will need to provide the database connection information.
Depending on selected Persistence layer implementation appsettings json files will contain one of configuration sections:

  • for MongoDB
  "MongoDbSettings": {
    "ConnectionString": "",
    "DatabaseName": ""
  }
  • for MS SQL
  "ConnectionStrings": {
    "MyDbConnectionString": ""
  }

If MS SQL persistence implementation was selected during solution creation you have to run migrations on your database. This step can be done with following commands run from the root directory of your solution (assuming you have installed the "dotnet ef" tools)

  dotnet ef database update -p src/your-solution-name.Persistence.MsSql.Migrations/ -s src/your-solution-name.Persistence.MsSql.Migrations/ --connection 'your-connection-string' 

For more information on Entity Framework Core tools see Entity Framework Core tools reference

After that you can launch the API project from Visual Studio or from command-line.

Support

If you are having problems, please let us know by raising a new issue.

License

This project is licensed with the MIT license.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Release includes the following improvements:
   - fixes of using directives for minimal APIs contract models
   - [Serializable] attribute added to custom DomainException
   - added several empty folders to Infrastructure project to guide users what should be implemented there