问题:AppService 正在插入 3 行而不是 1 行。我想要实现的是 3 个实体之间多对多关系的链接表。它似乎正在三个实体之间创建每种类型的链接之一,一个真假一个假的真一个真实的真实但我不明白为什么。我相信这可能与 EF Core 有更多关系,但我不确定这里出了什么问题。我觉得这可能与导航属性有关,我删除了它们,但结果保持不变。public class ModelOne : FullAuditedEntity<long>, IMustHaveTenant{ public virtual int TenantId { get; set; } public virtual ICollection<ResLink> ResLinks { get; set; }}public class ModelTwo : FullAuditedEntity<long>, IMustHaveTenant{ public virtual int TenantId { get; set; } public virtual ICollection<ResLink> ResLinks { get; set; }}public class ModelThree : FullAuditedEntity<long>, IMustHaveTenant{ public virtual int TenantId { get; set; } public virtual ICollection<ResLink> ResLinks { get; set; }}public class ResLink : FullAuditedEntity<long>, IMustHaveTenant{ public virtual int TenantId { get; set; } public virtual long? ModelOneId { get; set; } public virtual ModelOne ModelOne { get; set; } public virtual long? ModelTwoId { get; set; } public virtual ModelTwo ModelTwo { get; set; } public virtual long? ModelThreeId { get; set; } public virtual ModelThree ModelThree { get; set; } }public async Task CreateResLink() { var res = new ResLinkDto { TenantId = 1, ModelOneId = 1, ModelTwoId = 1, ModelThreeId = 180026 }; await _resLinkRepository.InsertAsync(ObjectMapper.Map<ResLink>(res));}插入结果:ID |Date |User Id| M.Date| M.User |IsDeleted| D.Uid |D.Time| TenantId |ModelOneId |ModelTwoId| ModelThreeId30050 06/08/2019 13:26:54 6 NULL NULL False NULL NULL 1 1 NULL 18002630051 06/08/2019 13:26:54 6 NULL NULL False NULL NULL 1 NULL 1 180026 30052 06/08/2019 13:26:54 6 NULL NULL False NULL NULL 1 1 1 180026
添加回答
举报
0/150
提交
取消