In my Odata web api I've generated my entities with Entity Framework Database first, then i want to add the annotation [key] to a field so i follow this indications : https://stackoverflow.com/a/16737247/6444829 to create a metadata class then a partial class and then add the annotation in the metadata class.
when i do so it doesn't consider the annotation and i got an error "The entity 'XXXX' does not have a key defined".
what am'i doing wrong, the annotation [Key] is it different from others ?
public partial class personalInfo
{
public int personId { get; set; }
public int primaryPosition_id { get; set; }
...
}
[MetadataType(typeof(personalInfoMetaData))]
public partial class personalInfo
{
}
public class personalInfoMetaData
{
[Key]
public int personId { get; set; }
[ForeignKey("positionInfo")]
public int primaryPosition_id { get; set; }
}
ps : its a view that was retrieved from the database and transformed in an entity.