Create Views for object properties in model in MVC 3 application?

后端 未结 2 396
一个人的身影
一个人的身影 2021-01-24 01:59

I have an Asp.Net MVC 3 application with a database \"Consultants\", accessed by EF. Now, the Consultant table in the db has a one-to-many relationship to several other tables f

2条回答
  •  走了就别回头了
    2021-01-24 02:35

    You may take a look at the following blog post about writing custom object templates. Also don't use EF models in your views. Design view models that are classes specifically tailored to the needs of a given view and have your controller map between the EF models and the view models that should be passed to the view. AutoMapper is a good tool that could simplify this mapping.

提交回复
热议问题