View Model Example in MVC5

ViewModel in Asp.Net MVCThe viewmodel in mvc represent only the data we want to display on view whether it is used for displaying or for taking input from view. If we want to display more than one model on view in mvc then we need to create a new viewmodel. Following image shows visual representation of view model in mvc.

Here we will learn mvc viewmodel with simple example if we have a Customer entity and Order entity. In view to display both entities (Customer entity + Order entity) data then we need to create viewmodel (CustomerVM) and we will select the properties whichever we want to display from both entities (Customer entity + Order entity) and create a viewmodel.

Now start with creating a viewmodel in mvc before that let's have look on table which we are going to use in our application.
Database PartIn this database part we will create required tables in database with following scripts.
Customer Tablefollowing is the script to c…

Default RouteConfig fix for Area in MVC || RAJESH GAMI