ASP.NET MVC is a presentation framework. To build a large application, a few more architectural components are required. In the post, a greeting is retrieved from the database and displayed in the UX.

Data Access Layer

Data access layer is distributed into three assemblies:

  1. HelloWorldApp.Entities
  2. HelloWorldApp.Repositories
  3. HelloWorldApp.Repositories.Contracts

Greeting class

IGreetingRepository interface

GreetingRepository class

Business Logic Layer

The business logic layer is distributed into two assemblies:

  1. HelloWorldApp.Services
  2. HelloWorldApp.Services.Contracts

IGreetingService interface

GreetingService class

Presentation Layer

The presentation layer is distributed in two assemblies:

  1. HelloWorldApp.Models
  2. HelloWorldApp

GreetingModel class

HomeController class

Index view

Design idea

Central to the design is the separation of concerns between Entities and Models. Entities have the responsibility of mapping to database tables. Models are used by the presentation layer to represent data. The business logic layer performs the mapping of entities to models. This might appear as if we are over-engineering the system. But, it is required for large applications.

Download the complete source code. HelloWorldApp

Entities and Models in large ASP.NET MVC application
Tagged on:     

Leave a Reply

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