Categories: ASP.NETASP.NET MVC

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

Step 11. Create the Infrastructure project of the onion architecture, which name sets “Enterprise_MVC_WebApplication.Infra.” The infrastructure project performs operations related to outside the applications, including the database operation, accessing outside service, and the access file system.

Fig 15 Onion architecture in solution explorer

Step 12. Create a ADO.NET Entity Data Model file which name is “DemoDB_Entities.” Right-click on the Enterprise_MVC_WebApplication.Infra project -> Add -> New item.

Fig 16 Add new items to infra project

Create a ADO.NET Entity Data Model file which name is “DemoDB_Entities.”

If your class library is based on the .Net framework and the .Net Core framework, you can use the entity framework 6.X. You only must add the core project to the infra project reference. If your .Net standard version is 2.0, please install a few of the NuGet package by NuGet package manager in Visual Studio 2017. If your .Net standard version is 2.1, you don’t need to install these NuGet packages because the .Net standard of the 2.1 version has the entity framework 6(EF 6). Remember that the infra project must add the core project to the reference part of the infra project.

  • Microsoft.EntityFrameworkCore v3.1
  • Microsoft.EntityFrameworkCore.Sqlserver v3.1
  • Microsoft.Configuration.Json v2.2

Note: If you use the class library of the .Net Standard 2.0, you must use the dbContext method of the ASP.Net Core framework.

Step 13. Create the Repository file in Enterprise_MVC_WebApplication.Infra project. Write the function about Add, FindByID, Remove…etc.

Fig 20. Repository source code

Page: 1 2 3 4

davidsky69

View Comments

Recent Posts

Behavioral Patterns – Template method

Template method – It means the program defines an algorithm skeleton in the superclass, which lets subclasses…

4 years ago

Behavioral Patterns – Strategy

Strategy – It allows the programs to define a family of an algorithm, put each…

4 years ago

Behavioral Patterns – State

State – This pattern can let the program’s object alter its behavior when its internal state changes,…

4 years ago

Behavioral Patterns – Observer

Observer – It lets the programs define a subscription mechanism to notify multiple objects, which means when…

4 years ago

Behavioral Patterns – Null Object

Null Object – Designed to act as a default value of an object. From Design Pattern –…

4 years ago

Behavioral Patterns – Memento

Memento – It allows the programs to save and restore the object’s previous state without revealing its…

5 years ago