Can anyone understand this error?
During model generation, one or more validation errors were detected:
System.Data.Edm.EdmEntityType :: EntityType 'Address' does not have a key. Define a key for this EntityType . System.Data.Edm.EdmEntitySet: EntityType: EntitySet addresses are based on the Address type, which does not have specific keys.
I defined this entity:
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; }
}
My question is: how does the error make sense for a class that has an annotation of key attribute data, as well as a conditional name for its PC.
I would think that this class satisfies all the rules necessary to create a meaningful entity.
source
share