最近从.NET Framework 转写一个EFCore,原来的实体模型不能用,用Code First发现这个问题,

存在两个实体

AppuUser类

EFcore两个实体两个一对多关系实现问题探讨

Account类

EFcore两个实体两个一对多关系实现问题探讨

两个实体存在两队一对多关系,即一个用户拥有多个账户,一个用户可以Check多个账户,在Account内增加两个标量外键和导航属性,在Appusr内增加两个Icollection导航属性。

以上,执行Add Migration时发现无法确定Account.Appuser Owner的外键关系。报错:Unable to determine the relationship represented by navigation property 'Account.Owner' of type 'AppUser'. Either manually configure the relationship, or ignore this property using the '[NotMapped]' attribute or by using 'EntityTypeBuilder.Ignore' in 'OnModelCreating'.

那么如何打FK标签属性才能正确让EFCore确认关系呢

相关文章: