AsNoTracki或者全局禁用

protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
// 关闭EF Core默认追踪
optionsBuilder.UseQueryTrackingBehavior(QueryTrackingBehavior.NoTracking);

optionsBuilder.EnableDetailedErrors();
}

EF Corexxxxnstance with the same key value for {'Id'} is already being tracked.的更多相关文章

  1. The instance of entity type 'Menu' cannot be tracked because another instance with the same key value for {'Id'} is already being tracked.

    这里记录一个在使用.net core中ef core执行数据库操作时遇到的问题: 我在代码中使用DbContext下的Update方法准备将更改后的数据像这样步到数据库: _context.Menus ...

  2. The instance of entity type 'xxxx' cannot be tracked because another instance with the same key value for {'Id'} is already being tracked.

    一.问题描述 问题:The instance of entity type 'xxxx' cannot be tracked because another instance with the sam ...

  3. The instance of entity type 'manager' cannot be tracked because another instance with the same key value for {'id'} is already being tracked. When attaching existing entities, ensure that only one ent

    最近在用ASP.NET CORE时遇到一些问题,现记录下: 出现上述错误,即在更新实体数据时出现的错误 services.AddDbContext<StoreContext>(c => ...

  4. entity cannot be tracked

    背景:EF Core项目中使用InMemory作为数据库提供程序,编写单元测试. 报错:“The instance of entity type 'Movie' cannot be tracked b ...

  5. 【WPF】EntityframeworkCore Update注意事项

    The instance of entity type 'Book' cannot be tracked because another instance with the same key valu ...

  6. 9.3 翻译系列:数据注解特性之Key【EF 6 Code-First 系列】

    原文链接:http://www.entityframeworktutorial.net/code-first/key-dataannotations-attribute-in-code-first.a ...

  7. EF Core中Key属性相同的实体只能被跟踪(track)一次

    在EF Core的DbContext中,我们可以通过DbContext或DbSet的Attach方法,来让DbContext上下文来跟踪(track)一个实体对象,假设现在我们有User实体对象,其U ...

  8. .NetCore之EF跳过的坑

    我在网上看到很多.netCore的信息,就动手自己写一个例子测试哈,但是想不到其中这么多坑: 1.首先.netCore和EF的安装就不用多说了,网上有很多的讲解可以跟着一步一步的下载和安装,但是需要注 ...

  9. EF使用CodeFirst方式生成数据库&技巧经验

    前言 EF已经发布很久了,也有越来越多的人在使用EF.如果你已经能够非常熟练的使用EF的功能,那么就不需要看了.本文意在将自己使用EF的方式记录下来备忘,也是为了给刚刚入门的同学一些指导.看完此文,你 ...

  10. EntityFramework之摸索EF底层(八)

    前言 此篇文章我将深入去摸索edmx中一些不为人知的东西,有时候我们需要知道Code  First模型中一些存储以及映射的原理,个人觉得那是必要的也是有用的,因为很有可能SQL会出现一些其他问题,只有 ...

随机推荐

  1. 02.JavaScript学习笔记1

    1.强制类型转换 当使用加号进行运算时,会将数字强制转换为字符串,然后再进行运算. const year = '1991'; console.log(year + 18); console.log(t ...

  2. uniapp 打包app 引入高德地图

    一.高德地图注册key值 二.项目中添加配置 三.项目中引用 <view class="home-btom-box" > <view class="ho ...

  3. react项目中如何出现config文件夹

    答案:运行  npm run eject  即可出现config文件夹 原因: 在package.json中:只有三个依赖,分别是react,react-dom,react-scripts,依赖为什么 ...

  4. What's new in Dubbo 3.1.4 and 3.2.0-beta.3

    在 12 月 22 日,Dubbo 3.1.4 和 3.2.0-beta.3 正式通过投票发布.本文将介绍发布的变化一览. Dubbo 3.1.4 版本是目前 Dubbo 3 的最新稳定版本,我们建议 ...

  5. python内存机制

    内存机制 先从较浅的层面来说,Python的内存管理机制可以从三个方面来讲 (1)垃圾回收 (2)引用计数 (3)内存池机制 一.垃圾回收: python不像C++,Java等语言一样,他们可以不用事 ...

  6. C/S UDP通信实践踩坑记录与对于ICMP的进一步认识

    背景 最近有个业务场景需要服务端(简称S)与客户端(简称C)设计一套基于UDP的通信协议--要求尽可能快的前提下可容忍一定丢包率,得以比较深入地学习和了解UDP通信和实践,在开发调试期间先后碰到了C端 ...

  7. [常用工具] PyAutoGUI使用教程

    PyAutoGUI使用教程 目录 PyAutoGUI使用教程 1 基础知识 2 一般函数 3 故障保险 4 鼠标函数 4.1 鼠标移动 4.2 鼠标拖动 4.3 鼠标单击 4.4 鼠标滚动 4.5 鼠 ...

  8. 企业应用架构研究系列二十五:IdentityServer4 认证服务搭建

    IdentityServer4 更新了开源协议,曾经想替换它,不在使用IdentityServer4 ,但是后来,研究来研究去,发现IdentityServer4 的功能实在是强大,设计体系完整,随着 ...

  9. 安装部署Java项目

    开头:之前做了个文档转换的小项目,想部署在安卓手机上,自己可以随时看看,所以才有了下面这篇文章,内容或有瑕疵,望请批正.文末放我自己部署文档转换网址,仅供大家参考,谢谢! 选择:Termux 还是 L ...

  10. 深入Typescript--02-Typescript数据类型

    基本类型 一.最最基础的类型 布尔.数字.字符串类型 let bool:boolean = true; let num:number = 10; let str:string = 'hello wor ...