Model in MVC in
Simple Way
In MVC ‘M’
stands for Model. In MVC model is used to create logic class for any MVC
application. We can put all our project logic called business logic in model in
MVC.
In this
example I am creating model in a simple way. In my next article I will discuss
model with strongly view.
For this
example I am taking controller name Home and method name is Index and create
view for this index method.
To add model
Right click on model folder from solution explorer ->go to add->class
Figure 1
Give a
proper name to the class. I have given the name EmployeeData. In this class I
have created some variable to store data. The code of this class is as
follows:-
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace MvcApplication5.Models
{
public class EmployeeData
{
public int EmpId;
public string EmpName;
public string EmpDept;
public int salary;
}
}


