我正在使用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?)
我该如何解决?
答案 0 :(得分:0)
要使用KeyAttribute
和ColumnAttribute
,您应该添加定义它们的程序集。
因此,您应该在项目中添加System.ComponentModel.DataAnnotations
的引用。
在Reference Manager中找到它 - >装配 - >框架。