实体框架SaveChanges正在保存不变的记录(通过存储过程映射) [英] Entity Framework SaveChanges is saving unchanged record (via stored procedure mapping)
问题描述
我在附加了2个实体的上下文中调用saveChanges.实体"A"收到对其值的更新,"B"不变.
I'm calling saveChanges on a context that has 2 entities attached. Entity 'A' receives updates to it's values, 'B' does not change.
当我在SaveChanges之前的行上暂停代码并检查'B'实体时,它说"EntityState = Unchanged(2)".
When I pause the code on the line before SaveChanges, and inspect the 'B' entity and it says "EntityState = Unchanged(2)".
我让代码完成运行,最后执行存储过程,该存储过程已映射到"B"实体的Update执行中.
I let the code finish running and I end up with the Store Procedure that is mapped to the 'B' Entity's Update executing.
我希望这不会发生,为什么?
I expected that this would not happen, why is it?
谢谢戈德
EF 4.0.30319
EF 4.0.30319
推荐答案
我怀疑这个问题是那个问题的重复.
要重复给出的答案:
这是在以下情况下发生的问题:
That is an issue that happens when:
- .NET Framework 4.0版上的运行实体框架;
- 使用自定义映射SQL代码;
可以通过3种方法之一解决此问题:
The issue can be fixed in 1 of 3 ways:
- 从Microsoft获取并部署 MS KB 2390624 中描述的修补程序-该请求需要付费Microsoft的协助(例如通过公司支持合同);
- 升级到.NET 4.5(如果您不必再担心Windows XP,则只能选择此选项);
- 升级到Entity Framework 6(目前处于beta版,但我希望它不会出现该错误);
- Get and deploy the hotfix from Microsoft described on MS KB 2390624 - that request requires paid assistance from Microsoft (e.g. through a company support contract);
- Upgrade to .NET 4.5 (only an option if you do not have to worry about Windows XP anymore);
- Upgrade to Entity Framework 6 (currently in beta, but I would expect it to not exhibit that bug);
这篇关于实体框架SaveChanges正在保存不变的记录(通过存储过程映射)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!