Categories: ASP.NETASP.NET MVC

Building MVC pattern project by Visual Studio 2017 ( ASP.Net framework Part )

Step 6. Create the core project that is the class library project. The core project should include two items, such as Domain entities and Repository interfaces. It should not have any external dependencies, for example, the reference of the ORM(LINQ to SQL or EF), the reference of ADO.NET libraries, and the reference of Entity Framework.

Fig 11 Create new project

The core project name sets “Enterprise_MVC_WebApplication.Core.”

Fig 12 Add new project dialog box

Step 7. Install the System.ComponentModel.DataAnnotations by Nuget package manager.

Fig 13 Install the System.ComponentModel.DataAnnotations

Step 8. Add the new class file which name is the Enterprise_MVC_Core files.

 using System;
 using System.ComponentModel.DataAnnotations;
 namespace Enterprise_MVC_WebApplication.Core
 {
     public class Enterprise_MVC_Core
     {
         public int ID { get; set; } = 0;
         [Required]     
         [MaxLength(50)]     
         public string Name { get; set; } = string.Empty;     
         public int Age { get; set; } = 0; 
     }
 }

Step 9. Create the Interface folder under the core project.

Step 10. Add the new class file, which name is “IEnterprise_MVC_CoreRepository.”

Fig 14. the interface file source code of the core project
 using System.Collections.Generic;
 namespace Enterprise_MVC_WebApplication.Core.Interface
 {
     public interface IEnterprise_MVC_CoreRepository
     {
         void Add(Enterprise_MVC_Core o);
         void Edit(Enterprise_MVC_Core o);
         void Remove(int ID);
         IEnumerable GetData();
         Enterprise_MVC_Core FindById(int ID);
     }
 }

Page: 1 2 3 4

davidsky69

View Comments

Recent Posts

SOLID Principles – Single-responsibility principle

The single-responsibility principle (SRP) is a computer-programming principle that states that every module, class or…

4 years ago

Microservices – Command and Query Responsibility Segregation(CQRS)

Command query responsibility segregation (CQRS) generalizes CQS to message-driven and event-driven architectures: it applies the CQS…

4 years ago

Microservices – Domain-driven design(DDD)

Domain-driven design (DDD) is a software design approach focusing on modelling software to match a…

4 years ago

Microservices – Onion architecture

A microservice architecture – a variant of the service-oriented architecture (SOA) structural style – arranges…

4 years ago

Unit Of Work pattern concepts in .NET

The Repository pattern and Unit of Work pattern are used together in most time. Unit…

4 years ago

Behavioral Patterns – Visitor

Visitor – It allows the program changes the algorithm and the operations that base on the visitor…

4 years ago