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 ...
随机推荐
- 最常用的Eclipse快捷键
最常用的Eclipse快捷键 2015/03/27 | 分类: 基础技术 | 0 条评论 | 标签: ECLIPSE 分享到:0 原文出处: IT江湖 本文是一些最实用.最齐全.最省时间的 Eclip ...
- $.ajax()方法详解(转)
以下内容转自:http://www.cnblogs.com/tylerdonet/p/3520862.html 尊重原创,请访问原创文章 jquery中的ajax方法参数总是记不住,这里记录一下. ...
- PHP把时间转换成几分钟前、几小时前、几天前的几个函数、类分享
这篇文章主要介绍了php计算时间几分钟前.几小时前.几天前的几个函数.类分享,需要的朋友可以参考下一.函数实现实例1: <?php header("Content-type: text ...
- BEC listen and translation exercise 37
You're supposed to do that before 10.30 in the morning, but obviously, if it's an emergency, you can ...
- debian服务查询
1.查询 用root身份执行service --status-all查看所有服务的状态 "+" started "-" stopped "?" ...
- MySQL读取各个my.cnf配置文件的先后顺序是:
/etc/my.cnf /etc/mysql/my.cnf /usr/local/mysql/etc/my.cnf ~/.my.cnf 其他自定义路径下的my.cnf,例如:/data/mysql/y ...
- 【转】 Pro Android学习笔记(五七):Preferences(1):ListPreference
目录(?)[-] 例子1ListPreference小例子 定义一个preferences XML文件 继承PreferenceActivity 用户定制偏好的读取 第一次运行时设置缺省值 设置Cat ...
- 关于openstack自动化安装的一点思考
在openstack针对具体应用的解决方案已成型之后,按照官方文档安装openstack实际上就成了一个繁琐的事情. 我有一个设想,之前实施了一点,还未成功,但是也想记录下来.最终目标:使用U盘直接部 ...
- ES6学习之Generator函数
概念:可以把Generator 函数理解成状态机(封装了多个内部状态)或者是一个遍历器对象生成函数 写法:Generator函数的定义跟普通函数差不多,只是在function关键字后面加了一个星号 f ...
- net start sql server (instance)
如何启动 SQL Server 实例(net 命令) 其他版本 可以使用 Microsoft Windows net 命令启动 Microsoft SQL Server 服务. 启动 SQL Se ...