ef代码中的注释列首先不起作用

时间:2015-02-06 17:41:15

标签: c# .net entity-framework

我正在使用EntityFramework,Version = 6.0.0.0

我的命名空间是:

using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.Design;

我的班级是:

public class KalaType
{

[Key, Column(Order = 0)]
public int kalaID { get; set; }
[Key, Column(Order = 1)]
public int typeID { get; set; }
... 

}

但显示此错误:

Compiler Error Message: CS0246: The type or namespace name 'Column' could not be found (are you missing a using directive or an assembly reference?)

我该如何解决?

1 个答案:

答案 0 :(得分:0)

要使用KeyAttributeColumnAttribute,您应该添加定义它们的程序集。
因此,您应该在项目中添加System.ComponentModel.DataAnnotations的引用。
在Reference Manager中找到它 - >装配 - >框架。