出现这个错误:

   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();

 

为啥会自动插入记录呢?

相关文章:

  • 2021-12-15
  • 2021-08-20
  • 2022-02-09
  • 2021-10-04
  • 2021-11-01
  • 2022-12-23
猜你喜欢
  • 2021-07-08
  • 2021-06-24
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-13
相关资源
相似解决方案