What is Model in ASP.NET MVC

78
what is model in mvc

Model in ASP.NET MVC

In this article, we will learn about what is Model in MVC framework with an example.

The model represents domain-specific data and business logic in MVC architecture. It maintains the data of the application. Model objects retrieve and store model state in the persistent store like a database.

The model class holds data in public properties. All the Model classes reside in the Model folder in the MVC folder structure.

MVC Model Class Example

Let’s see how to add a model class in ASP.NET MVC architecture with an example.

Adding a Model

Open our first MVC project created in the previous step in the Visual Studio. Right click on Model folder -> Add -> click on Class..

In the Add New Item dialog box, enter the class name ‘Student’ and click Add.

Create Model Class

 

This will add a new Student class in the model folder. Now, add Id, Name, Age properties as shown below.

Example: Model class

So in this way, you can create a model class which you can use in View.

Conclusion

I hope you liked this article about what is a Model in MVC. I would like to have feedback from my blog readers. Your valuable feedback, question, or comments about this article are always welcome.

LEAVE A REPLY

Please enter your comment!
Please enter your name here