有人能理解这个错误吗?
在模型生成期间检测到一个或多个验证错误:
System.Data.Edm.EdmEntityType: : EntityType 'Address' 没有定义键。定义此 EntityType 的键。System.Data.Edm.EdmEntitySet:EntityType:EntitySet 地址基于没有定义键的类型地址。
我定义了这个实体:
public class Address
{
[Key]
public int ID;
[Required]
[MinLength(1)]
[MaxLength(200)]
public string Address1 { get; set; }
[MinLength(1)]
[MaxLength(200)]
public string Address2 { get; set; }
[Required]
[MinLength(1)]
[MaxLength(10)]
public string Zip { get; set; }
[MinLength(1)]
[MaxLength(100)]
public string Province { get; set; }
public virtual US_State State { get; set; }
[Required]
public virtual Country Country { get; set; }
}
我的问题是:对于既具有 Key 属性数据注释以及其 PK 的常规 ID 名称的类,该错误有什么意义。
我认为这个类满足从它生成有意义的实体所需的所有规则。