A starter kit for your next ASP.NET Core web application. Boilerplate for ASP.NET Core reference application, demonstrating a layered application architecture w
A starter kit for your next ASP.NET Core web application. Boilerplate for ASP.NET Core reference application, demonstrating a layered application architecture w
The best path to leverage your ASP.NET Core skills. Onboarding to Full Stack .Net Core Developer jobs. Boilerplate for ASP.NET Core reference application with Entity Framework Core, demonstrating a layered application architecture with DDD best practices. Implements NLayer Hexagonal architecture (Core, Application, Infrastructure and Presentation Layers) and Domain Driven Design (Entities, Repositories, Domain/Application Services, DTO's...) and aimed to be a Clean Architecture, with applying SOLID principles in order to use for a project template. Also implements best practices like loosely-coupled, dependency-inverted architecture and using design patterns such as Dependency Injection, logging, validation, exception handling, localization and so on.
You can check full repository documentations and step by step development of 100+ page e-book PDF from here - https://aspnetrun.azurewebsites.net. Also detail introduction of book and project structure exists on medium aspnetrun page. You can follow aspnetrun repositories for building step by step asp.net core web development skills.
Here you can find all of the aspnetrun repositories from easy to difficult, Also this list can be track a learning path of asp.net core respectively;
For this repo, there is also implemented base repository and applying real-world e-commerce examples with developing new enterprice features for example Identity, Paging, Localization etc.. Check below repository;
Here is CRUD operations of aspnetrun-core template project;
run-aspnetcore is a general purpose to implement the Default Web Application template of .Net with layered architecture for building modern web applications with latest ASP.NET Core & Web API & EF Core technologies.
If you liked the project or if AspnetRun helped you, please give a star. And also please fork this repository and send us pull-requests. If you find any problem please open issue.
Use these instructions to get the project up and running.
You will need the following tools:
Follow these steps to get your development environment set up:
dotnet restoredotnet builddotnet runIf you have Visual Studio after cloning Open solution with your IDE, AspnetRun.Web should be the start-up project. Directly run this project on Visual Studio with F5 or Ctrl+F5. You will see index page of project, you can navigate product and category pages and you can perform crud operations on your browser.
After cloning or downloading the sample you should be able to run it using an In Memory database immediately. The default configuration of Entity Framework Database is "InMemoryDatabase". If you wish to use the project with a persistent database, you will need to run its Entity Framework Core migrations before you will be able to run the app, and update the ConfigureDatabases method in Startup.cs (see below).
public void ConfigureDatabases(IServiceCollection services)
{
// use in-memory database
services.AddDbContext(c =>
c.UseInMemoryDatabase("AspnetRunConnection")
.UseQueryTrackingBehavior(QueryTrackingBehavior.NoTracking));
//// use real database
//services.AddDbContext(c =>
// c.UseSqlServer(Configuration.GetConnectionString("AspnetRunConnection"))
// .UseQueryTrackingBehavior(QueryTrackingBehavior.NoTracking));
}Ensure your connection strings in appsettings.json point to a local SQL Server instance.
Open a command prompt in the Web folder and execute the following commands:
dotnet restore
dotnet ef database update -c AspnetRunContext -p ../AspnetRun.Infrastructure/AspnetRun.Infrastructure.csproj -s AspnetRun.Web.csprojOr you can direct call ef commands from Visual Studio Package Manager Console. Open Package Manager Console, set default project to AspnetRun.Infrastructure and run below command;
update-databaseThese commands will create aspnetrun database which include Product and Category table. You can see from AspnetRunContext.cs.
If you modify-change or add new some of entities to Core project, you should run ef migrate commands in order to update your database as the same way but below commands;
add migration YourCustomEntityChanges
update-databaseAspnetRun implements NLayer Hexagonal architecture (Core, Application, Infrastructure and Presentation Layers) and Domain Driven Design (Entities, Repositories, Domain/Application Services, DTO's...). Also implements and provides a good infrastructure to implement best practices such as Dependency Injection, logging, validation, exception handling, localization and so on. Aimed to be a Clean Architecture also called Onion Architecture, with applying SOLID principles in order to use for a project template. Also implements and provides a good infrastructure to implement best practices like loosely-coupled, dependency-inverted architecture The below image represents aspnetrun approach of development architecture of run repository series;
Repository include layers divided by 4 project;
Development of Domain Logic with abstraction. Interfaces drives business requirements with light implementation. The Core project is the center of the Clean Architecture design, and all other project dependencies should point toward it..
Includes Entity Framework Core Entities which creates sql table with Entity Framework Core Code First Aproach. Some Aggregate folders holds entity and aggregates. You can see example of code-first Entity definition as below;
…Applying domain driven approach, Product class responsible to create Product instance.
Abstraction of Repository - Domain repositories (IAsyncRepository - IProductRepository) - Specifications etc.. This interfaces include database operations without any application and ui responsibilities.
This folder is implementation of specification pattern. Creates custom scripts with using ISpecification interface. Using BaseSpecification managing Criteria, Includes, OrderBy, Paging. This specs runs when EF commands working with passing spec. This specs implemented SpecificationEvaluator.cs and creates query to AspnetRunRepository.cs in ApplySpecification method.This helps create custom queries.
Implementation of Core interfaces in this project with Entity Framework Core and other dependencies. Most of your application's dependence on external resources should be implemented in classes defined in the Infrastructure project. These classes must implement the interfaces defined in Core. If you have a very large project with many dependencies, it may make sense to have more than one Infrastructure project (eg Infrastructure.Data), but in most projects one Infrastructure project that contains folders works well. This could be includes, for example, e-mail providers, file access, web api clients, etc. For now this repository only dependend sample data access and basic domain actions, by this way there will be no direct links to your Core or UI projects.
Includes Entity Framework Core Context and tables in this folder. When new entity created, it should add to context and configure in context. The Infrastructure project depends on Microsoft.EntityFrameworkCore.SqlServer and EF.Core related nuget packages, you can check nuget packages of Infrastructure layer. If you want to change your data access layer, it can easily be replaced with a lighter-weight ORM like Dapper.
EF add-migration classes.
EF Repository and Specification implementation. This class responsible to create queries, includes, where conditions etc..
Custom services implementation, like email, cron jobs etc.
Development of Domain Logic with implementation. Interfaces drives business requirements and implementations in this layer. Application layer defines that user required actions in app services classes as below way;
public interface IProductAppService
{
Task> GetProductList();
Task GetProductById(int productId);
Task> GetProductByName(string productName);
Task> GetProductByCategory(int categoryId);
Task Create(ProductDto entityDto);
Task Update(ProductDto entityDto);
Task Delete(ProductDto entityDto);
}Also implementation located same places in order to choose different implementation at runtime when DI bootstrapped.
…In this layer we can add validation , authorization, logging, exception handling etc. -- cross cutting activities should be handled in here.
Development of UI Logic with implementation. Interfaces drives business requirements and implementations in this layer. The application's main starting point is the ASP.NET Core web project. This is a classical console application, with a public static void Main method in Program.cs. It currently uses the default ASP.NET Core project template which based on Razor Pages templates. This includes appsettings.json file plus environment variables in order to stored configuration parameters, and is configured in Startup.cs.
Web laye
No open issues yet, or sync has not completed.