AHutak.OnionArchitecture.AspNet
2.0.0
See the version list below for details.
dotnet new install AHutak.OnionArchitecture.AspNet::2.0.0
ASP.NET Onion Architecture Solution Template
Template Description
This is a template package with two solution templates:
- ASP.NET Web API application,
- gRPC application. Both of these solutions are built by following the Onion Architecture. You can create a new solution based on one of these templates by installing the associated NuGet package and using it from Visual Studion 2022 and later or directly with DotNet CLI commands.
Each template contains:
- Domain, Application, Persistence, Infrastructure, and API projects,
- MS SQL and MongoDB persistence layer implementations wich user can choose during solution creation,
- Optional Entity Framework migrations project,
- Unit tests and Component tests template projects,
The template of your choise contains either:
- API project with REST minimal API's and, optionally, standard controllers
- API project with gRPC service
Getting Started
Installing the templates
To install this package 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
After that you have several options, to use it either from Visual Studio 2022 or from command-line.
From Visual Studio 2022:
From command-line:
dotnet new oa-sln-aspnet-grpc -n Your-Project-Name
or
dotnet new oa-sln-aspnet-webapi -n Your-Project-Name
To view other available command-line solution parameters please run
dotnet new oa-sln-aspnet-grpc --help
or
dotnet new oa-sln-aspnet-webapi --help
At the moment these templates support 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.
-
net6.0
- coverlet.collector (>= 3.2.0)
- FluentAssertions (>= 6.8.0)
- Grpc.AspNetCore (>= 2.50.0)
- Microsoft.AspNetCore.Mvc.Testing (>= 6.0.11)
- Microsoft.EntityFrameworkCore.SqlServer (>= 7.0.1)
- Microsoft.EntityFrameworkCore.Tools (>= 7.0.1)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 7.0.0)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 7.0.0)
- Microsoft.NET.Test.Sdk (>= 17.4.1)
- Microsoft.VisualStudio.Azure.Containers.Tools.Targets (>= 1.17.0)
- MongoDB.Driver (>= 2.18.0)
- Moq (>= 4.18.3)
- MSTest.TestAdapter (>= 3.0.0)
- MSTest.TestFramework (>= 3.0.0)
- Swashbuckle.AspNetCore (>= 6.4.0)
-
net7.0
- coverlet.collector (>= 3.2.0)
- FluentAssertions (>= 6.8.0)
- Grpc.AspNetCore (>= 2.50.0)
- Microsoft.AspNetCore.Mvc.Testing (>= 7.0.0)
- Microsoft.EntityFrameworkCore.SqlServer (>= 7.0.1)
- Microsoft.EntityFrameworkCore.Tools (>= 7.0.1)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 7.0.0)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 7.0.0)
- Microsoft.NET.Test.Sdk (>= 17.4.1)
- Microsoft.VisualStudio.Azure.Containers.Tools.Targets (>= 1.17.0)
- MongoDB.Driver (>= 2.18.0)
- Moq (>= 4.18.3)
- MSTest.TestAdapter (>= 3.0.0)
- MSTest.TestFramework (>= 3.0.0)
- Swashbuckle.AspNetCore (>= 6.4.0)
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:
- gRPC solution template added to the package,
- added support for .NET 7,
- all dependencies upgraded to latest versions,
- Persistence.Migrations project is made optional