.NET 6 using Onion Architecture – Part 6 – Architecture Skeleton Completed – PwP Episode 10

Challenges

  • Building a complete architecture skeleton in .NET 6.
  • Ensuring the skeleton adheres to Onion Architecture principles.
  • Balancing initial complexity with future scalability.

Solutions

  • Developing a foundational architecture skeleton for long-term project growth.
  • Employing Onion Architecture for separation of concerns and maintainability.
  • Utilizing .NET 6 features to streamline foundational design.

Benefits

  • A scalable and maintainable base for software projects.
  • Clear separation of core logic, infrastructure, and presentation layers.
  • Faster onboarding and development through a standardized skeleton.

In this episode, Jeffrey is going to finish the Onion Architecture series with .NET 6. This is the culmination of a 6-part series creating, from scratch, a .NET 6 application using Onion Architecture. It’s been built up starting with the core, the private build, a continuous integration build, unit tests, and integration tests. An interface to the SQL server database has been added on and then capped off with a Blazor WebAssembly application. This series will finish with refactoring dependency resolution. Making sure the references are correct from one project to the other is very important with Onion Architecture.

Code Sample: https://github.com/jeffreypalermo/onion-architecture-dotnet-6/tree/issue-5-ui-and-startup-complete

Project references are really important! You don’t want to accidentally have any interfaces referencing other interface projects. Every major interface gets its own project because the Onion Architecture is not for tiny applications. If you have a tiny application, then just create one project, and put it all in there and you’re done. Onion Architecture is for applications where the code base is going to grow. You’re going to have multiple people on the team, and you want it to be obvious which project code goes into it. You don’t want to have IntelliSense suggesting the use of certain classes; objects, APIs, interfaces, etc., that are not appropriate to put in certain places therefore we break it out into projects.

We have intentional project references and then it forces us to stay true to the architecture that we decided we were going to go after. This episode will add the Lamar IOC container project and introduce the health check service APIs. This will introduce a project to start things up, make sure everything’s factored in its own place and then clone the repository, run the private bill, open visual studio, run the project, and by the end of it, you can use this code as a skeleton for any of your applications. If you’re using .NET 6 Blazor WebAssembly or SQL Service Entity Framework, it has a power shell. In previous episodes, you can learn how to get it running on Azure pipelines and GitHub actions.