Javatpoint Logo
Javatpoint Logo

ASP.NET MVC Model

A model is a class that contains the business logic of the application. It also used for accessing data from the database. The model class does not handle directly input from the browser. It does not contain any HTML code as well.

Models are also refers as objects that are used to implement conceptual logic for the application. A controller interacts with the model, access the data, perform the logic and pass that data to the view.


Creating a Model

Let's add a new model in exiting project. Model contains setter and getter for its properties. To add the model, just right click on the Model folder of the project and then follow this sequence Model->Add->New Item->Visual C#->Code->Class.

ASP Mvc model 1

It contains some default code as given below.

// ClassicalMusic.cs

Now, we can add any number of properties and methods in the model. These are helpful to make MVC a clean framework approach. As here, we are creating some properties and a method.

// ClassicalMusic.cs







Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA