且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

MVC中数据库表如果是一对一的主键关系时要加[Required]不然会出错Unable to determine the principal end of an association between the types

更新时间:2022-01-16 04:24:56

Unable to determine the principal end of an association between the types '***. The principal end of this association must be explicitly configured using either the relationship fluent API or data annotations.

 

 [Required]  
 public virtual User User { get; set; }

 解决的是如下情况:

MVC中数据库表如果是一对一的主键关系时要加[Required]不然会出错Unable to determine the principal end of an association between the types

学习交流群:364976091