Categories: ASP.NETASP.NET Core

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

Step 4. Create a new class library project called the Core project based on the ASP.NET Core framework. Right-click on solution item -> Add -> New project.

Fig 6 Create a new class library project

Step 5. Select “Class Library(.NET Core)”, then click “Add” button. The core project name sets “Enterprise_Dot_Net_Core_WebApp.Core.”

Fig 7 Create new class library project dialog box

Step 6. Create the Interface folder under the core project. Change the default class file name from “class1.cs” to “Enterprise_MVC_Core.cs.”

Fig 8 Core project solution explorer

Edit the Enterprise_MVC_Core.cs file, then adding some codes in the Enterprise_MVC_Core.cs file.

Fig 9. Enterprise_MVC_Core source code
 using System;
 using System.Collections.Generic;
 using System.ComponentModel.DataAnnotations;
 using System.ComponentModel.DataAnnotations.Schema;
 using System.Text;
 namespace Enterprise_Dot_Net_Core_WebApp.Core.Entities
 {
     [Table("Enterprise_MVC_Core")]
     public class Enterprise_MVC_Core
     {
         [Key]
         public int ID { get; set; }
     public string Name { get; set; }     public int? Age { get; set; }  }
 }

Step 7. Create the Entities folder, then move the Enterprise_MVC_Core file to the Entities folder. Create the new class file, whose name is “IEnterprise_MVC_CoreRepository.”

Fig 10. Core project solution explorer with the Entities folder and the Interface folder

Step 8. Add interface source code in the IEnterprise_MVC_CoreRepository file.

Fig 11 IEnterprise_MVC_CoreRepository source code
 using System;
 using System.Collections.Generic;
 using System.Text;
 using Enterprise_Dot_Net_Core_WebApp.Core.Entities;
 namespace Enterprise_Dot_Net_Core_WebApp.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