小编nzk*_*arl的帖子

为什么MVC3不支持我的外键列

我正在尝试使用MVC 3和EF 4.1首先使用代码并遵循Scott Guthries教程 http://weblogs.asp.net/scottgu/archive/2011/05/05/ef-code-first-and-data- scaffolding-with-the-asp-net-mvc-3-tools-update.aspx.

我遇到的问题是,当我创建产品控制器和相关的脚手架视图时,在任何视图中都没有创建"类别"列("编辑","创建","索引"等),应该创建根据教程.

我已经跟踪了没有显示列的原因是因为t4模板...它没有检查它是否是可绑定类型以便将属性显示为列.

检查它是否可绑定的逻辑是:

bool IsBindableType(Type type) {
return type.IsPrimitive || bindableNonPrimitiveTypes.Contains(type);
}
Run Code Online (Sandbox Code Playgroud)

其中bindableNonPrimitiveTypes是固定列表:

static Type[] bindableNonPrimitiveTypes = new[] {
typeof(string),
typeof(decimal),
typeof(Guid),
typeof(DateTime),
typeof(DateTimeOffset),
typeof(TimeSpan),
};
Run Code Online (Sandbox Code Playgroud)

我刚刚安装了VS2010 sp1,EF 4.1和本教程引用的MVC3工具更新.我确定我已经按照所有步骤......

我哪里错了/我错过了什么?

code-first entity-framework-4.1 asp.net-mvc-3

2
推荐指数
1
解决办法
4781
查看次数