In this Video, I am going to discuss the Models in an ASP.NET MVC Application with Examples. Please read our previous Video before proceeding to this Video where we discussed Views in an ASP.NET MVC Application. As part of this Video, we are going to discuss the following pointers which are related to MVC Models.

- What are the Models in ASP.NET MVC?
- How to create and use Models in MVC.
What are the Models in ASP.NET MVC?
The Models in ASP.NET MVC application are the component which contains a set of classes that are used to represent the business data (or domain data) as well as logic to manage the business data. So in simple words, we can say that the model in ASP.NET MVC is used to manage the domain data i.e. the state of the application in memory.
Note: It is not mandatory, but it is a good programming practice to store all model classes within the Models folder of an ASP.NET MVC application.
Let us see an example to understand the Models in ASP.NET MVC.
We need to display the employee information on a webpage as shown below.
In order to store the employee data, we are going to use the Employee model class. To do so, right-click on the “Models” folder and then select Add => Class option. Provide the name as Employee.cs and finally click on the Add button as shown in the image below.
Now open the Employee.cs class file and then copy and paste the following code.
This is our Employee model which is going to hold the employee data in memory. As we already discussed, the Models in ASP.NET MVC Framework also contain the business logic to manage the business data. So in our example, in order to manage the employee data i.e. to perform the CRUD operation on the employee data, we are going to use the following EmployeeBusinessLayer model.
Creating EmployeeBusinessLayer Model:
Right-click on the Models folder and then add a new class file with the name EmployeeBusinessLayer.cs. Once you create the EmployeeBusinessLayer class file, then copy and paste the following code into it.
Once you created the required models for your application, then the model folder structure should look like below.
Modifying the HomeController
Now let us modify the HomeController class as shown below to use the Employee and EmployeeBusinessLayer model to retrieve the employee data.
Thats it. In the next Video, we will discuss how to pass the employee model data to a view, so that the view generates the necessary HTML.