Model represents an object. Model is resposible for maintaining the data
It respond to the request from view. It also respond to the instruction from controller for the updation.
Model objects retrieve and store model state in a database.
For example, a Student object might retrieve information from a StudentData Database, operate on it, and then write updated information back to a StudentData table in a SQL Server database.
In MVC, model both hold and manipulate application data. It contains all the application logic except view and controller logic
Model Folder contains the classes of application.
We can add models to our application with the following steps
- A model folder will be present under the created application's Solution Explorer.
- Right click on Model folder. A list will be appearing
- Select 'Add' option from list.Then a new list will be coming.
- Then select 'Class' option from list
- A new window appearing.Here give the name for the new class or model and select 'Add'.(Say model name as SampleModel)
- The newly added class will be appearing.That is, this will create a model class to the application.
- Inside this class, we can add properties as per the requirements. Example is given below.