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);
     }
 }

1 Comment

Leave a Reply