EF Corexxxxnstance with the same key value for {'Id'} is already being tracked.
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.的更多相关文章
- 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 ...
- 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 ...
- 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 => ...
- entity cannot be tracked
背景:EF Core项目中使用InMemory作为数据库提供程序,编写单元测试. 报错:“The instance of entity type 'Movie' cannot be tracked b ...
- 【WPF】EntityframeworkCore Update注意事项
The instance of entity type 'Book' cannot be tracked because another instance with the same key valu ...
- 9.3 翻译系列:数据注解特性之Key【EF 6 Code-First 系列】
原文链接:http://www.entityframeworktutorial.net/code-first/key-dataannotations-attribute-in-code-first.a ...
- EF Core中Key属性相同的实体只能被跟踪(track)一次
在EF Core的DbContext中,我们可以通过DbContext或DbSet的Attach方法,来让DbContext上下文来跟踪(track)一个实体对象,假设现在我们有User实体对象,其U ...
- .NetCore之EF跳过的坑
我在网上看到很多.netCore的信息,就动手自己写一个例子测试哈,但是想不到其中这么多坑: 1.首先.netCore和EF的安装就不用多说了,网上有很多的讲解可以跟着一步一步的下载和安装,但是需要注 ...
- EF使用CodeFirst方式生成数据库&技巧经验
前言 EF已经发布很久了,也有越来越多的人在使用EF.如果你已经能够非常熟练的使用EF的功能,那么就不需要看了.本文意在将自己使用EF的方式记录下来备忘,也是为了给刚刚入门的同学一些指导.看完此文,你 ...
- EntityFramework之摸索EF底层(八)
前言 此篇文章我将深入去摸索edmx中一些不为人知的东西,有时候我们需要知道Code First模型中一些存储以及映射的原理,个人觉得那是必要的也是有用的,因为很有可能SQL会出现一些其他问题,只有 ...
随机推荐
- @ApiImplicitParams注解的详细使用
一.@ApiImplicitParams注解的详细使用 业务需求: 1.根据服务员类别id(单个id)+服务员星级id(id的list)查询对应的服务员列表 1.controller代码: 点击查看代 ...
- SQLMap入门——获取当前网站数据库的用户名称
列出当前网站使用的数据库用户 python sqlmap.py -u http://localhost/sqli-labs-master/Less-1/?id=1 --current-user
- 【机器学习】李宏毅——AE自编码器(Auto-encoder)
1.What 在自编码器中,有两个神经网络,分别为Encoder和Decoder,其任务分别是: Encoder:将读入的原始数据(图像.文字等)转换为一个向量 Decoder:将上述的向量还原成原始 ...
- drf快速使用 CBV源码分析 drf之APIView分析 drf之Request对象分析
目录 序列化和反序列化 drf介绍和安装 使用原生django写接口 django DRF安装 drf快速使用 模型 序列化类 视图 路由 datagrip 使用postman测试接口 CBV源码分析 ...
- PowerUsageSummary.java源码分析
在在线网站http://androidxref.com/上对Android版本6.0.1_r10源码进行分析 官方手机的应用耗电排行具体实现位置在:/packages/apps/Settings/sr ...
- 算法之倍增和LCA:论点与点之间的攀亲戚
前言 我们在做树形题和图论题时常常遇到这样的问题:要求求出树上两点间的最近公共祖先(LCA),这时我们该怎么办? 思路一:暴力爬爬爬-- 很容易想到让两个点都往上爬,啥时候相遇了就是他们的最近公共祖先 ...
- 基于 VScode 搭建 Verilog 自动格式化
插件 Verilog-HDL/SystemVerilog/Bluespec SystemVerilog SystemVerilog and Verilog Formatter 工具 https://g ...
- 定时任务,LocalDateTime,在代码中调用其他项目的接口url
1.定时任务 1.在类上添加注解 @Component @Configuration @EnableScheduling 2.在类中方法上添加注解 @Scheduled(cron = "0 ...
- day04-视图和视图解析器
视图和视图解析器 1.基本介绍 在SpringMVC中的目标方法,最终返回的都是一个视图(有各种视图) 注意,这里的视图是一个类对象,不是一个页面!! 返回的视图都会由一个视图解析器来处理(视图解析器 ...
- RESTful相关信息整理
RESTful相关信息整理 参考:可以看的出来我是阮一峰的忠实读者 阮一峰的<理解RESTful架构> https://www.ruanyifeng.com/blog/2011/09/re ...