在MVC 4表属性无法识别 [英] Table attribute in MVC 4 is not recognized

查看:104
本文介绍了在MVC 4表属性无法识别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有类似下面的模型:

[Table("forms", Schema = "mySchema")]
public class forms
{
  [Key]
  public int ID { get; set; }
  public string field1 { get; set; }
  public string field2 { get; set; }
}

这工作在MVC 3,但在MVC 4属性表中无法识别。我已经包括System.ComponentModel.DataAnnotations命名空间,该DLL引用,与EntityFramework.dll一起。 EF的版本MVC 3和4之间变化。如果我引用MVC 3 EF DLL,表是公认的,但是架构是没有的。之所以使用表属性,所以我可以指定模式。我缺少什么?

This works in MVC 3, however in MVC 4 the attribute Table in not recognized. I have the System.ComponentModel.DataAnnotations namespace included, and the dll referenced, along with EntityFramework.dll. The version of EF has changed between MVC 3 and 4. If I reference the MVC 3 EF dll, Table is recognized, however Schema is not. The reason for using the table attribute is so I can specify the schema. What am I missing?

推荐答案

据MSDN上的<一个href=\"http://msdn.microsoft.com/en-us/library/system.componentmodel.dataannotations.schema.tableattribute.aspx\"相对=nofollow> TableAttribute 支持架构属性。

According to msdn the TableAttribute supports the schema property.

也许是:

[Table(Name = "forms", Schema = "mySchema")]

这篇关于在MVC 4表属性无法识别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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