Entity Framework 6.1.0 - Get an error while using Command Interceptor

落爺英雄遲暮 提交于 2019-12-20 05:47:15

问题


In my application I do the following

  1. Read from database: I Fetch items from database (In parallel, with context per each Task).

  2. Write to database: I Create a new Context and for each fetched item, I attach it to that new
    context

  3. I defined an Interceptor because I don't want that the EF will save the changes (I need to do it by myself, later, because of performance)

  4. The problem - after I call SaveChanges() method, the Interceptor being invoked and I have the SQL statement and it's OK. BUT, after the code is executed in the Interceptor side, there is an exception on the Context.SaveChanges() method. Saying that: "Store update, insert, or delete statement affected an unexpected number of rows (0). Entities may have been modified or deleted since entities were loaded. Refresh ObjectStateManager entries."

anyone can help me solve this issue ?

thanks.

Hagai

来源:https://stackoverflow.com/questions/27437630/entity-framework-6-1-0-get-an-error-while-using-command-interceptor

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!