NetActive.CleanArchitecture.Application.Persistence.Interfaces
6.2.1
See the version list below for details.
dotnet add package NetActive.CleanArchitecture.Application.Persistence.Interfaces --version 6.2.1
NuGet\Install-Package NetActive.CleanArchitecture.Application.Persistence.Interfaces -Version 6.2.1
<PackageReference Include="NetActive.CleanArchitecture.Application.Persistence.Interfaces" Version="6.2.1" />
paket add NetActive.CleanArchitecture.Application.Persistence.Interfaces --version 6.2.1
#r "nuget: NetActive.CleanArchitecture.Application.Persistence.Interfaces, 6.2.1"
// Install NetActive.CleanArchitecture.Application.Persistence.Interfaces as a Cake Addin #addin nuget:?package=NetActive.CleanArchitecture.Application.Persistence.Interfaces&version=6.2.1 // Install NetActive.CleanArchitecture.Application.Persistence.Interfaces as a Cake Tool #tool nuget:?package=NetActive.CleanArchitecture.Application.Persistence.Interfaces&version=6.2.1
NetActive.CleanArchitecture
NetActive.CleanArchitecture is a set of libraries supporting Clean Architecture development in .NET (6+).
Source code and examples can be found on GitHub. The NuGet packages, including debug symbols, can be found on NuGet.
Quick Getting Started Guide
These libraries assume you have SQL Server Express LocalDB installed, but they work with any SQL Server version supported by Entity Framework Core.
You can verify if you have SQL Server Express LocalDB installed by running this command:
SqlLocalDB info
You should get this response:
MSSQLLocalDB
If you didn't, then first download and install SQL Server Express LocalDB. Once you have SQL Server Express LocalDB installed, you follow the simple steps below.
You will end-up with a new solution containing a basic console application, but the scaffolded Application, Domain and Persistence projects can also be used in Website or WebApi projects, like all the included example projects do.
- Open a .NET Core command line interface
- Install the solution template from NuGet:
dotnet new install NetActive.CleanArchitecture.Template
- Create and navigate to an empty folder that will hold the Solution (by default the folder name will be used as the primary namespace):
dotnet new cleanarch-console
(add-h
for more options)
- Navigate to the subfolder created, who's name ends with
.Console
- Run the console application:
dotnet run
It might take a few seconds to create the database. Then the output should be:
d87d6081-fdbd-42c7-9e8d-4d297410c6aa some entity
d730df59-bd8c-42d1-8133-6699aa47db42 some other entity
51f2d429-9a53-44b5-9205-f02883ab8bbe yet another entity
Entity 'some entity' exists: True
Alternatively you can also run this command from the Package Manager Console:
PM> Install-Package NetActive.CleanArchitecture.Template
Once installed you can choose the template from Visual Studio's Create a new project
wizard, like any other installed solution or project template.
You can remove the solution template by running this command:
dotnet new uninstall NetActive.CleanArchitecture.Template
Example Code
Besides the source code you'll also find many practicle examples on how to use these libraries in Console applications, Web applications or API's.
Here's a quick example (from the Example.Console.CommandAdd
example project) of what your application code could look like (excluding some global usings):
using Example.Application.Manufacturer.Configuration;
using Example.Application.Manufacturer.Commands.AddManufacturer;
using Example.Application.Manufacturer.Commands.AddManufacturer.Models;
// Build a host.
var host = Host.CreateDefaultBuilder()
.ConfigureServices((hostContext, services) =>
{
// Wire up our clean architecture dependencies.
services
.AddPersistenceDependencies<ExampleDbContext, IExampleUnitOfWork, ExampleUnitOfWork>(
hostContext.Configuration.GetConnectionString("ExampleDbConnection1"),
options =>
{
options.RegisterEfRepository<Manufacturer, Guid>();
})
.AddApplicationManufacturerDependencies();
})
.Build();
// Create manufacturer model.
var manufacturerName = $"My Manufacturer ({DateTime.Now:yyyyMMddHHmmsssmmm})";
var manufacturerToAdd = new AddManufacturerCommandModel(manufacturerName)
{
Contact =
{
FamilyName = "Brink",
GivenName = "Raymond" // Optional
}
};
// Execute add manufacturer command.
var result = await host.Services.GetRequiredService<IAddManufacturerCommand>().ExecuteAsync(manufacturerToAdd);
Console.WriteLine($"Added: {result}: {manufacturerToAdd.ManufacturerName}");
Console.WriteLine();
Why create these libraries?
Inspired by the video series Clean Architecture: Patterns, Practices and Principles on PluralSight by Matthew Renze, I started creating these libraries around the idea of Clean Architecture a few years ago.
The open source community has given me so much over the past decade, I decided it was time to give something back. Since I find them very practicle and I recently ported them to .NET 6 and Entity Framework Core 6, I felt it was the right time to share these Clean Architecture libraries with the rest of the world.
Focus is on simplifying implementation of and support for these Clean Architecture patterns and practices in new .NET projects. These libraries have already been under active development for a few years and applied in real life production applications many times.
Please check them out and feel free to share your thoughts and ideas by contacting me or submitting a pull request.
Background
Under the hood these libraries try to apply the following principles and patterns:
- Clean Code
- Don't Repeat Yourself
- SOLID:
- Command and Query Responsibility Segregation (CQRS)
- Facade Pattern
- Factory Method Pattern
- Repository and Unit of Work Patterns
If you're a programmer and you haven't heared of these yet, please check out Uncle Bob Martin and Martin Fowler. You might learn a thing or two 😉
Check out these projects as they are priceless and essential for these libraries to shine:
Happy coding!
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. 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. |
-
net6.0
- No dependencies.
NuGet packages (3)
Showing the top 3 NuGet packages that depend on NetActive.CleanArchitecture.Application.Persistence.Interfaces:
Package | Downloads |
---|---|
NetActive.CleanArchitecture.Persistence
Handles generic data access and persistence |
|
NetActive.CleanArchitecture.Application.EntityFrameworkCore
Handles command and query construction and execution for Entity Framework Core |
|
NetActive.CleanArchitecture.Application.MediatR
Adds support for event sourcing to the Application layer using MediatR. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
6.3.0 | 482 | 9/28/2023 |
6.2.1 | 366 | 9/5/2023 |
6.1.0 | 368 | 8/23/2023 |
6.1.0-alpha.2 | 65 | 8/18/2023 |
6.1.0-alpha.1 | 65 | 8/18/2023 |
6.0.9 | 1,312 | 4/28/2023 |
6.0.8 | 570 | 3/20/2023 |
6.0.7 | 592 | 2/28/2023 |
6.0.5 | 648 | 2/18/2023 |