创建强类型视图时出现无法确定复合主键的错误

Getting error unable to determine composite primary key while creating strongly typed view

我正在开发 ASP.NET-MVC 应用程序,我正在尝试从控制器创建强类型视图,但出现以下错误,如图

所示

型号class

public class PropertyRentingApplication
{
     public PropertyRentingApplication() { }


     [Key]
     [Display(Name = "Application ID")]
     public int ApplicationID { get; set; }

     [Key, ForeignKey("PropertyType")]
     [Display(Name = "Property Type ID")]
     [Required(ErrorMessage = "Require Property Type ID")]
     public int PropertyTypeID { get; set; }

     [Key, ForeignKey("Student")]
     [Display(Name = "Student ID")]
     [Required(ErrorMessage = "Require Student ID")]
     public int StudentID { get; set; }

     [Display(Name = "Application Reference")]
     [MaxLength(150)]
     [Required(ErrorMessage = "Application Reference")]
     public string ApplicationReference { get; set; }

     [Display(Name = "Date Of Application")]
     [Required(ErrorMessage = "Require Date of Application Been Submitted")]
     public System.DateTime DateOfApplication { get; set; }

     [Display(Name = "Secure Entire Property")]
     [Required(ErrorMessage = "Require Information on If You Want to Secure Entire Property")]
     public bool SecureEntireProperty { get; set; }

     [Display(Name = "Application Status")]
     [MaxLength(50)]
     [Required(ErrorMessage = "Require Application Status")]
     public string ApplicationStatus { get; set; }

     public PropertyType PropertyType { get; set; }
     public Student Student { get; set; }

}

我已经更新如下“[Column(Order = 1)]”,但仍然遇到同样的错误

[Key]
     [Display(Name = "Application ID")]
     [Column(Order = 0)]
     public int ApplicationID { get; set; }

     [Key, ForeignKey("PropertyType")]
     [Display(Name = "Property Type ID")]
     [Column(Order = 2)]
     [Required(ErrorMessage = "Require Property Type ID")]
     public int PropertyTypeID { get; set; }

     [Key, ForeignKey("Student")]
     [Display(Name = "Student ID")]
     [Column(Order = 1)]
     [Required(ErrorMessage = "Require Student ID")]
     public int StudentID { get; set; }

您需要使用 [Column(Order = 0)][Column(Order = 1)] 等修饰键列,以定义这些列在键中的显示顺序