У меня есть следующее определение класса для объекта Code First:
public class Matches
{
[Key]
[Required]
[Column(Order = 1)]
public Guid MatchGroup { get; set; }
[Key]
[Required]
[Column(Order = 2)]
public long ProcedureId { get; set; }
public long MatchLevelId { get; set; }
[ForeignKey("ProcedureId")]
public virtual Procedure Procedure { get; set; }
[ForeignKey("MatchLevelId")]
public virtual ProcedureMatchLevel MatchLevel { get; set; }
}
Однако при создании моей первоначальной миграции я получаю следующую ошибку:
Unable to determine composite primary key ordering for type
'Entities.Procedures' Use the ColumnAttribute or the HasKey
method to specify an order for composite primary keys.
Как видите, я использую атрибут [Column]
.
Кто-нибудь сталкивался с этим вопросом раньше? Я попытался переключить свойство, в котором включено объявление [ForeignKey]
, используя [Key, ForeignKey("Procedure")]
с той же ошибкой.
Класс процедур:
[Table("ProcedureList")]
public class Procedure
{
[Required]
public int ProcedureId { get; set; }
[Required]
public string Code { get; set; }
[Required]
public string Description { get; set; }
}