2015-02-06 66 views
0

我使用的EntityFramework,版本= 6.0.0.0注释列codefirst不工作​​

我的命名空间:

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

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

+0

thanx为您的答案。我在“添加引用 - ”.NET中找到它并点击它。但它说:网站已经引用程序集'System.ComponentModel.DataAnnotations'! :( – angel 2015-02-07 04:13:02

+0

您正在使用哪种.NET框架版本 – alterfox 2015-02-07 12:58:46

+0

我正在使用版本4 – angel 2015-02-07 13:46:04