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 same key value for {'Id'} is already being tracked. When attaching existing entities, ensure that only one entity instance with a given key value is attached.
二、解决方案
就是把插入的主键自动赋值即可 id=SequentialGuidGenerator.Instance.Create();
三、示例
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 '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 ...
- EF 更新实体 The instance of entity type 'BabyEvent' cannot be tracked because another instance
加上AsNoTracking. 人不能两次踏入同一条河. 我 就踏入了.o(╥﹏╥)o
- 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 => ...
- [转] EF cannot be tracked because another instance of this type with the same key is already being tracked
本文转自:http://stackoverflow.com/questions/6033638/an-object-with-the-same-key-already-exists-in-the-ob ...
- type parameters of <T>T cannot be determined; no unique maximal instance exists for type variable T with upper bounds int,java.lang.Object
今天在进行代码检查的时候出现下面的异常: type parameters of <T>T cannot be determined; no unique maximal instance ...
- The entity type XXX is not part of the model for the current context.
今天遇到了一个奇葩问题,虽然解决了,但还是一脸懵,先附赠一下别人的解决方案:https://www.cnblogs.com/zwjaaron/archive/2012/06/08/2541430.ht ...
- Flask - 访问返回字典的接口报错:The view function did not return a valid response. The return type must be a string, tuple, Response instance, or WSGI callable, but it was a dict.
背景 有一个 Flask 项目,然后有一个路由返回的是 dict 通过浏览器访问,结果报错 关键报错信息 TypeError: 'dict' object is not callable The vi ...
- Entity Framework 6如何进行导航属性的筛选(context.Msg.First(t=>t.Id==1).Include(t=>t.MsgDetail),筛选MsgDetail带条件)
问题: https://q.cnblogs.com/q/98333/ Msg表(Id,Content,IsDel).内有 virtual ICollection<MsgDetail> Ms ...
- The entity type <type> is not part of the model for the current context
这是在网站里遇到的一个错误,自动生成的不能手动添加, reference: http://stackoverflow.com/questions/19695545/the-entity-type-xx ...
随机推荐
- 算法(Algorithms)第4版 练习 1.3.42
After copy Left on Stack r: be to not or be to Left on Stack copy: be to not or be to After r pop Le ...
- Spring- 通过Xml的方式完成Bean的实例化
传统应用程序可以通过反射方式进行实例化Bean,而Spring Ioc 容器则需要根据Bean定义的配置元数据使用反射机制来创建Bean.在Spring Ioc 容器中主要有以下几种创建Bean实例的 ...
- Codeforces 509F Progress Monitoring:区间dp【根据遍历顺序求树的方案数】
题目链接:http://codeforces.com/problemset/problem/509/F 题意: 告诉你遍历一棵树的方法,以及遍历节点的顺序a[i],长度为n. 问你这棵树有多少种可能的 ...
- 分享知识-快乐自己:SpringBoot集成热部署配置(一)
摘要: 热部署与热加载: ava热部署与Java热加载的联系和区别: 1):Java热部署与热加载的联系: 1.不重启服务器编译/部署项目 2.基于Java的类加载器实现 2):Java热部署与热加载 ...
- PHP消息队列用法实例分析
这篇文章主要介绍了PHP消息队列用法,结合实例形式分析了PHP消息队列用于Linux下进程间通信的相关技巧,需要的朋友可以参考下 该消息队列用于linux下,进程通信 队列状态信息:具体参考手册
- Python调试时__name__ =='__main__'的妙用
# python 文件自己运行,__name__的值就会等于__main__# 别的文件导入执行时,变成了导入文件的名字 例如: niuniu.py文件中,文件自己执行时,__name__的值就是__ ...
- bzoj 3083 遥远的国度 —— 树链剖分
题目:https://www.lydsy.com/JudgeOnline/problem.php?id=3083 换根后路径还是不变,子树分类讨论一下,树剖后线段树维护即可. 代码如下: #inclu ...
- JavaScript下的进制转换
JavaScript下的进制转换 //十进制转其他进制 var num = 99; console.log('十进制: ', num); console.log('八进制:', (num).toStr ...
- 代码实现跟控制器跳转到storyBoard
- Java精度计算与舍入
用到的类: 类 BigDecimal:不可变的.任意精度的有符号十进制数.BigDecimal 由任意精度的整数非标度值 和 32 位的整数标度 (scale) 组成.如果为零或正数,则标度是小数点后 ...