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. java中的instanceof方法

    本文主要讲述java中的instanceof()方法. 示例代码如下: public class InstanceTest { public static void main(String[] arg ...

  2. week_9(异常检测)

    Andrew Ng 机器学习笔记 ---By Orangestar Week_9 This week, we will be covering anomaly detection which is w ...

  3. 基于ZR.VUE 前端的改造,页面刷新报错

    问题描述: 前后端分离开发,分开部署. 页面刷新 直接报404 错误的解决办法 提示:  先在 .env.development 中 配置 VUE_APP_BASE_API , 将 '/' 替换为 后 ...

  4. MSIC总结取证分析——日志分析

    MSIC总结取证分析 一.日志分析: 1.常见日志分析类型: 2.常见一些考点: (1)还原特定IP攻击手段(SQL注入.暴力破解.命令执行等),或还原最初攻击时间: (2)寻找flag或者特定文件解 ...

  5. C語言成績分析系統

    C語言成績分析系統,可以實現七個功能.(使用的編譯器是 code::blocks) 主要實現對於學生信息的輸入 顯示輸入學生的信息 根據期末成績來進行排名. 查找某個學生的信息 刪除某個學生的信息 修 ...

  6. 图文并茂使用VUE+Quasar CLI开发和构建PWA,registerServiceWorker介绍

    看文档 文档地址:Preparation for PWA 1.将PWA模式添加到我们的Quasar项目中: npx quasar mode add pwa 我们看一下有哪些变化 向Quasar项目添加 ...

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

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

  8. ES中的内置对象--jquery如何优化代码,少用$进行查找,减少查找次数的方法

  9. Redis - 介绍与使用场景

    简介 Redis 的全称是 Remote Dictionary Server,是一个使用 C 语言编写的.开源的(BSD 许可)高性能非关系型(NoSQL)的键值对数据库. Redis 的数据是存储在 ...

  10. 如何通过Java应用程序添加或删除 PDF 中的附件

    当我们在制作PDF文件或者PPT演示文稿的时候,为了让自己的文件更全面详细,就会在文件中添加附件.并且将相关文档附加到 PDF 可以方便文档的集中管理和传输.那么如何添加或删除 PDF 中的附件呢?别 ...