我使用Visual Studio 2015年和Entity Framework版本6.0.0.0(代码第一次),我创建了一个类为:类型或命名空间名称“ForeignKey的”无法找到
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace IRANMVCCore.Domain.Entity
{
public class UserProperty
{
[key]
[ForeignKey("Instructor")]
[Required(ErrorMessage = "error")]
public string Name { get; set; }
[Required(ErrorMessage = "error")]
public string Famil { get; set; }
[Required(ErrorMessage = "error")]
public string City { get; set; }
[Required(ErrorMessage = "error")]
public string Countries { get; set; }
}
}
现在我正在此错误:
Error CS0246 The type or namespace name 'ForeignKey' could not be found (are you missing a using directive or an assembly reference?)
我已经参考: Refrances
我怎样才能解决呢?
不应该'[关键]'是'[Key]'? –
坦克[键]是[键]工作,但我仍然有错误“错误CS0246无法找到类型或命名空间名'ForeignKey'(你是否缺少使用指令或程序集引用?)” – NorouziFar