我正在研究ASP.NET-MVC应用程序,我正在尝试从控制器创建强类型视图,但我正在按照错误显示在图中
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; }
}
我已更新如下" [列(订单= 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; }
答案 0 :(得分:2)
您需要使用[Column(Order = 0)]
,[Column(Order = 1)]
等来装饰关键列,以定义这些列在关键字中的显示顺序