Posts

RAJESH GAMI - Blog

View Model Example in MVC5

Image
ViewModel in Asp.Net MVCThe viewmodel in asp.net 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 asp.net mvc then we need to create a new viewmodel. Following image shows visual representation of view model in asp.net mvc.

Here we will learn asp.net 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 asp.net 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