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. 《HTTP权威指南》– 10.安全HTTP

    HTTPS的概念 HTTPS 是最流行的HTTP安全模式,由网景公司首创,所有主流浏览器和服务器都支持此协议.HTTPS方案 的URL以 https:// 开头,使用 HTTPS 时,所有的HTTP请 ...

  2. python之yaml文件读取封装

    import os import yaml from yamlinclude import YamlIncludeConstructor YamlIncludeConstructor.add_to_l ...

  3. python 之用户自定义函数

    什么是函数? 函数无非就是将代码块进行封装,想用的时候拿来用,减少代码量,提高效率. 函数的定义 定义一个函数需要: 1.def关键字,def 后面空一格输入函数名称,函数命名时尽量简短,且具有意义, ...

  4. c++中编码protobuf repeated string

    参考:http://www.cppblog.com/API/archive/2014/12/09/209070.aspx proto文件 addressbook.proto syntax = &quo ...

  5. 速记·python 123章

    第一.二.三章 初识python 1.1 Python的概述 开发环境:Python 开发工具:IDLE(Python自带) 1.python的特点:代码简单.开发速度快.容易学习:有丰富的库:&qu ...

  6. Python实验报告(第7章)

    实验7:面向对象程序设计 一.实验目的和要求 1.了解面向对象的基本概念(对象.类.构造方法): 2.学会类的定义和使用: 3.掌握属性的创建和修改: 4.掌握继承的基本语法. 二.实验环境 软件版本 ...

  7. 克拉玛依初赛-wp

    MISC 签到 16进制转字符串 base64 再来一次base64 flag 论禅论道 7z解压得到jar 使用decom打开 解密 得到flag WEB pingme 抓包,修改POST提交的参数 ...

  8. Apache IoTDB C# SDK Apache-IoTDB-Client-CSharp

    最近今天写了IoTDB的三篇相关文章,完成了安装部署和客户端连接: Windows Server上部署IoTDB 集群 DBeaver 连接IoTDBDriver 将IoTDB注册为Windows服务 ...

  9. flutter_swiper:Another exception was thrown: ScrollController attached to multiple scroll views.

    Another exception was thrown: ScrollController attached to multiple scroll views. 翻译一下:引发了另一个异常:Scro ...

  10. MySQL8.0性能优化(实践)

    一台几年前的旧笔记本电脑的虚拟系统运行环境,作为本次实践的运行工具,仅供参考. 案例环境:Linux.Docker.MySQLCommunity8.0.31.InnoDB. 过早的MySQL版本不一定 ...