创建强类型的视图的ASP.NET MVC问题 [英] ASP.NET MVC Problem of creating strong-typed view

查看:303
本文介绍了创建强类型的视图的ASP.NET MVC问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我现在正在学习ASP.MVC。我创建强类型的视图中的一些问题。
我加了实体数据模型,以模型,然后我尝试添加基于实体数据模型我创建了一个强类型的视图。但我不能看到查看数据类的类添加视图对话框。

I'm learning ASP.MVC now. I got some problems of creating strong-typed view. I added Entity Data Model to Models, and then I tried to add a strong-typed view based on the Entity Data Model I created. But I cannot see any class in "View data class" in "Add View" dialog.

我错过sonmething?

Did I miss sonmething?

推荐答案

我的步骤做来做到这个份;

Steps I did to do this were;

在解决方案中下一个新项目,创建一个实体数据模型。

Create an entities data model in a new project under the solution.

使用模型浏览器的一些对象添加到EDM。

Add some objects to the EDM using the model browser.

做一个模型,类在我的MVC项目的模式文件夹,然后添加一些方法,从实体数据模型得到的对象。不要忘记引用你从你的MVC项目EDM项目。

Make a model class in the Models folder of my MVC project, then add some method that gets objects from the Entity Data Model. Don't forget to reference you EDM project from your MVC project.

在我的控制器创造学习一个新的ActionResult(或查看结果),得到它的要求是从模型文件夹中的模型对象。然后右键点击并创建视图...

In my controller cerate a new ActionResult (or View Result), get it to call for it's objects from the models folder model. Then right click and create view...

您将看到您的实体数据模型和你的模型文件夹视图中的数据类下拉列表对象。之所以使用该机型的文件夹,对我来说,这样我可以非常清楚当我懒加载的对象,比如,为了项目从父订单。

You should see your entities data model and your models folder objects in the view data class dropdown. The reason for using the models folder, for me, is so that I can make it very clear when I am lazy loading objects, for instance, order items from a parent order.

这篇关于创建强类型的视图的ASP.NET MVC问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆