ASP.NET Core Hero Boilerplate

ASP.NET Core Hero Boilerplate - .NET 5 Clean Architecture

ASP.NET Core Hero Boilerplate – Clean Architecture Solution Template for ASP.NET Core 5.0. Built with Onion/Hexagonal Architecture and incorporates the most essential Packages your projects will ever need. Includes both WebApi and Web(MVC) Projects.

Have you already Installed the Template?

make sure to update the template once every few days to stay updated.
you can reinstall the template again to get it updated.
Features

The Vision.

An idea to bring together the best and essential practices / pacakges of ASP.NET Core 5.0 along with Clean Hexagonal Architecture that can be a right fit for small/mid and enterprise level solutions. How easy would it be if you are able to run a single line of CLI command on your Console and you get a complete implementation in no time? That’s the exact vision I have while building this full fledged Boilerplate template.

How this Project can help you?

  • Generate Ready-made .NET 5 Clean Architecture Solutions within seconds!
  • A perfect starting point to learn about various essential packages and architecture.
  • Since the template includes both WebAPI and MVC, it suits literally any .NET enthusiast out there.
  • Feel free to contribute to this project and associated packages to build up your GitHub contributions 😀

As easy as this…

powershell Zq84E3BwLc ASP.NET Core Hero Boilerplate - .NET 5 Clean Architecture
aspnetcorehero-boilerplate-preview
aspnetcorehero boilerplate swagger preview ASP.NET Core Hero Boilerplate - .NET 5 Clean Architecture

Awesome things come in smaller packages!

Install the Nuget Package and Start Generating Pre-Built .NET 5 Solution with Clean Architecture (MVC & WebApi)

.NET 5 - WebAPI & MVC

This is a Standalone ASP.NET Core WebAPI Solution with multiple Layers of Abstraction. The Library Projects are build on .NET Core 3.1 Libraries / .NET Standard 2.1 Libraries.

One-Click Install

Clean Architecture for .NET 5 Solutions can be generated by just typing in a single line of Command. It can't get any easier than this!

Open Source

This Project is licensed under the MIT License, which means it is FREE to use, distribute. Feel free to contribute to this project as well. Let’s make this The Best Ever Template for .NET 5!

Getting Started with .NET 5 Clean Architecture

More Documentations coming soon.

Subscribe to codewithmukesh

Stay up to date! Get all the latest & greatest posts delivered straight to your inbox

Leave a Reply

Your email address will not be published. Required fields are marked *

31 Comments

  1. Hi Mukesh, thank you so much for this great work ! do you think it is a good idea to add 2 others projects to the template : an “integration test” project and a “unit test” project …. with samples to show how the tests should be approaches with architecture… ?

    Again, I really like your good job ! Thanks you !
    Mick

  2. I would like to let you know that I have cloned your source code from Github and build it in my development environment it is working fine, but when I try to publish this and host it to iis I am getting server error 500.
    I am getting issues on //Read Configuration from appSettings
    var config = new ConfigurationBuilder()
    .AddJsonFile(“appsettings.json”)
    .Build();
    Json Parsing issue.
    I have only made changes in the connection string and nothing else.

  3. This is awesome! I plan to play around with it this week. I am curious with everyone moving to Angular, React, or Vue; why did you chose MVC for the front end? I need to make this decision for a project and am curious on your input.

    1. Hi. Nothing very specific actually. People build client applications using React etc. But the project that I included is not a client application. It’s a complete application with direct access to the app layer without consuming the API. If I were to go for a client application, I would have chosen Angular or Blazor.

      Regards.

  4. Can you explain how we can publish the application (Clean Architecture Boilerplate – ASP.NET Core 5.0 (WebApi & MVC)

    1. I was able to get it to work with PostgreSQL, For Oracle it will be the same process but you’ll need to know which Oracle Nuget EF packages to install, steps:
      1. After installation, remove Nuget packages for Microsoft.EntityFrameworkCore.SqlServer for Web and Infrastructure Projects
      2. Add your equivalent Oracle EF Provider, for Postgresql it is Npgsql.EntityFrameworkCore.PostgreSQL and you must install it in the 2 projects abvove
      3. Delete all the migrations
      4. Change your connectionString to your specific DB in appSettings.json (for both webapi and web projects)
      5. Run migrations
      add-migration initial2 -context ApplicationDbContext
      add-migration initialIdentity2 -context IdentityContext
      6. Apply migrations
      update-database -context IdentityContext
      update-database -context ApplicationDbContext
      7. You’re good to go

  5. Hi Mukesh, Thank you so much for an amazing work!
    I’ve one question, how can we use ApplicationUser inside Domain project?
    For i.e
    public class Feedback
    {
    public int Id { get; set; }
    public string Note { get; set; }
    public string UserId { get; set; }
    public DateTime Created { get; set; }
    [JsonIgnore]
    public virtual ApplicationUser User { get; set; }
    }
    Here UserId is foreign key and using User as navigation property.
    But

  6. I would like to ask about one issue. I want to make a one to many relationship with the application user (aspnet user) for which I have a table named Office unit. So the scenario is , one office unit can have many users. How can I implement this relationship in the architecture if I implement a new Entity named OfficeUnit inside Core->Domain. Or I am getting this wrong? I am just learning it so I may be confused.
    Thanks.

  7. Truly Excellent Work Mukesh, well done!
    I was able to use it with PostgreSQL (I have detailed the steps in a reply to a comment below)
    but I have an issue, certain function Admin Settings>>Users gives the following erroe:

    An unhandled exception occurred while processing the request.
    NpgsqlOperationInProgressException: A command is already in progress: SELECT r.”Id”, r.”ConcurrencyStamp”, r.”Name”, r.”NormalizedName”
    FROM “Identity”.”Roles” AS r
    WHERE r.”Name” IN (‘Admin’, ‘Moderator’, ‘Basic’, ‘SuperAdmin’)

    Admin Settings>>Roles works fine

    From my research there may be a missing “await” and Npgsql is very strict that explains why the error not happening in SQLServer.

    Any thoughts on this Mukesh on how to make it work?

        1. Hi, have you resolved it? I encountered the same issue but have no idea how to solve it. Thanks!

      1. Hi, can you explain it in a little more detail? I encountered the same issue but have no idea how to solve it. Thanks!

        1. In UserRoleController, you chagne:
          public async Task Index(string userId)
          {
          var viewModel = new List();
          var user = await _userManager.FindByIdAsync(userId);
          ViewData[“Title”] = $”{user.UserName} – Roles”;
          ViewData[“Caption”] = $”Manage {user.Email}’s Roles.”;
          foreach (var role in _roleManager.Roles)
          {
          var userRolesViewModel = new UserRolesViewModel
          {
          RoleName = role.Name
          };
          if (await _userManager.IsInRoleAsync(user, role.Name))
          {
          userRolesViewModel.Selected = true;
          }
          else
          {
          userRolesViewModel.Selected = false;
          }
          viewModel.Add(userRolesViewModel);
          }
          var model = new ManageUserRolesViewModel()
          {
          UserId = userId,
          UserRoles = viewModel
          };

          return View(model);
          }
          To:
          public async Task Index(string userId)
          {
          var viewModel = new List();
          var user = await _userManager.FindByIdAsync(userId);
          ViewData[“Title”] = $”{user.UserName} – Roles”;
          ViewData[“Caption”] = $”Manage {user.Email}’s Roles.”;
          var roles = await _roleManager.Roles.ToListAsync();
          foreach (var role in roles)
          {
          var userRolesViewModel = new UserRolesViewModel
          {
          RoleName = role.Name
          };
          if (await _userManager.IsInRoleAsync(user, role.Name))
          {
          userRolesViewModel.Selected = true;
          }
          else
          {
          userRolesViewModel.Selected = false;
          }
          viewModel.Add(userRolesViewModel);
          }
          var model = new ManageUserRolesViewModel()
          {
          UserId = userId,
          UserRoles = viewModel
          };

          return View(model);
          }
          Notice, _roleManager.Roles is IQueryable, can not use in a foreach.

  8. Hi Mukesh, kudos on your work. Can you tell me how to return a list of validation errors from the ValidationBehavior class instead of throwing an exception, I have seen many GitHub repositories doing the same thing is there is any specific reason other than ease of implementation?
    I’m trying to achieve validation in my pipeline without throwing exceptions and want to wrap them in a response wrapper but finding it very hard to do so. Do you have any idea how to achieve it?