实体框架和多线程 [英] Entity Framework and multithreading
问题描述
Durng这个操作,我随机得到错误 - EntityMemberChanged或EntityComplexMemberChanged在没有首先调用EntityMemberChanging或EntityComplexMemberChanging的同一个更改跟踪器上调用,具有相同的属性名称。有关正确报告更改的信息,请参阅实体框架文档。
当特定属性的ReportPropetychanged事件被触发时,会抛出错误。
任何帮助将不胜感激。
请问
Andy
不要共享一个ObjectContext - 或任何连接到它的对象 - 线程之间。 记录为非线程安全的。
I have a WCF service that processes some messages. I use EntityFramework to retrieve the messages. I add these messages to a ThreadPool queue and then process them. After processing all the messages, I call an update on the Entity Framework to update the status of the messages.
Durng this operation, I randomly get the error - "EntityMemberChanged or EntityComplexMemberChanged was called without first calling EntityMemberChanging or EntityComplexMemberChanging on the same change tracker with the same property name. For information about properly reporting changes, see the Entity Framework documentation."
This error is thrown when the ReportPropetychanged event for a particular attribute gets fired.
Any help would be appreciated.
Regards
Andy
Don't share an ObjectContext -- or any object attached to it -- between threads. It is documented to be non-thread-safe.
这篇关于实体框架和多线程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!