我不断收到此错误,我不知道为什么。
“BioSheet.Models.BioSheetModel”类型的属性“Ward”上的 ForeignKeyAttribute 无效。在依赖类型“BioSheet.Models.BioSheetModel”上找不到外键名称“WardId”。Name 值应该是逗号分隔的外键属性名称列表。
public class Ward
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; set; }
[ForeignKey("AddressId")]
[Required]
public virtual Address WardAddress { get; set; }
[ForeignKey("BioSheetId")]
public virtual List<BioSheetModel> BioSheets { get; set; }
[Required]
public String Code { get; set; }
}
public class BioSheetModel
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; set; }
[Required]
public String FirstName { get; set; }
[Required]
public String LastName { get; set; }
public String Email { get; set; }
[ForeignKey("WardId")]
[Required]
public Ward Ward { get; set; }
public String CellPhoneNumber { get; set; }
public String HouseNumber { get; set; }
[Required]
public String DoB { get; set; }
[Required]
public Address Address { get; set; }
public String OtherInformation { get; set; }
public String PreviousCallings { get; set; }
[ForeignKey("TimePeriodId")]
public virtual TimePeriod TimePeriods { get; set; }
public String HomeWard { get; set; }
public Boolean OkToText { get; set; }
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
[Required]
public DateTime TodaysDate { get; set; }
[ForeignKey("EMPId")]
public virtual EDUEMP EduEmp { get; set; }
[ForeignKey("SingId")]
public virtual Sing Singing { get; set; }
[ForeignKey("MissionId")]
public virtual Mission MissionIn { get; set; }
}
谁能帮我解决这个问题?