我想在我的模型中创建一个列作为唯一键。如何在EF代码中的模型中为列添加唯一键首先
我的代码是:
public class Customer
{
[Index("abcd",IsUnique = true)]
public int CustomerID { get; set; }
}
,我使用以下参考资料:
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
不过我得到
Error 103 The type or namespace name 'IndexAttribute' could not be found (are you missing a using directive or an assembly reference?)
我失去了什么? 荫提前
已经在使用refrence – Santosh 2014-11-25 09:56:03
但你有这条线在你的代码文件的顶部? – DavidG 2014-11-25 09:56:20
是的,现在更改为代码文件的顶部。仍然不起作用 – Santosh 2014-11-25 09:58:47