efcore 关联插入

出现这个错误:

   at Microsoft.EntityFrameworkCore.DbContext.SaveChanges(Boolean acceptAllChangesOnSuccess)
Microsoft.EntityFrameworkCore.DbUpdateException: An error occurred while updating the entries. See the inner exception for details.
---> System.Data.SqlClient.SqlException: 当 IDENTITY_INSERT 设置为 OFF 时,不能为表 'XXXProjectJF' 中的标识列插入显式值。

但我保存context.saveChange()时,没有操作'XXXProjectJF' 这个表, 只是操作''XXXProjectAch' 这个表, 'XXXProjectAch' 这个表有一个ProjectJF的字段.

我只是做了查询

                                    c = new ProjectAch();

                                    c.CreateUser = LoginUserId;
                                    c.CreateDate = DateTime.Now;

                                    c.projectJF= _context.ProjectJFs
                                        .Where(t =>t.ProjectName == projectName .AsNoTracking().FirstOrDefault();

为啥会自动插入记录呢?

原文地址:https://www.cnblogs.com/zitjubiz/p/10944611.html