使用列属性的不明确引用

时间:2012-11-23 07:30:55

标签: visual-studio entity-framework

在一个项目中,我能够毫无问题地使用ColumnAttribute。

在另一个,不是。我在测试项目中有以下课程:

class TestClass_x
{
  [Key, Column(Order = 0)]
  public int i { get; set; }

  [Key, Column(Order = 1)]
  public string i2 { get; set; }

  public string str { get; set; }
}

导致

Ambigous reference:
 System.ComponentModel.DataAnnotations.Schema.ColumnAttribute
 System.ComponentModel.DataAnnotations.Schema.ColumnAttribute
match

我在测试项目中添加了以下引用:

  • EntityFramework(v 4.4.0.0)
  • 要测试的项目
  • 另一个测试项目
  • 第三个测试项目
  • Microsoft.VisualStudio.Quality.Tools.UnitTestFramework(v 10.0.0.0)
  • PresentationFramework(v 4.0.0.0)
  • 系统(v 4.0.0.0)
  • System.ComponentModel.DataAnnotations(v 4.0.0.0)

1 个答案:

答案 0 :(得分:2)

您使用的是.NET 4.5吗?在这种情况下,您将在System.ComponentModel.DataAnnotations.dll和EntityFramework.dll中都有ColumnAttribute。解决方案应该是将EntityFramework升级到5.0,因为4.4版仅适用于.NET 4.0。

相关问题