Virtual Classes Logo          Virtual Classes
    Read Anytime,Anywhere

Model

A model is a class which holds the data. A model basically act as a facilator/intermediator between View and Controller. When a controller wants to send some data to view it uses model to pass the data, when view wants to pass data to controller it uses model. A model holds all the required information that is needed to render the view.

To add a model to your MVC application.
1-Goto to solution explorer --> Right Click on Model folder-->Choose Add-->Choose Class
Belog image shows adding a model to a MVC application.

Adding a model to application

2-A dialog box will be opened. Give a name to the class and Click on "Add" button.
model in mvc

3- Add Properties to the class.
A model hold the data to render view so add only those properties which are needed to render the view.
I have created a Student model, this model has four property StudentID,StudentName,ContactNo and Address.
model class