EF 4.0 model caching the data, and does not detect the modified data

人盡茶涼 提交于 2019-11-28 11:26:44

This is correct behavior based on essential concepts of ORM. It also works same for Linq to SQL. The reason for this is design pattern called IdentityMap which ensures that each entity identified by its key is created only once for object context. So your first query creates entites but your subsequent queries don't recreate them - they already exists. The full description of this problem is described in this very nice article.

You can avoid this by using a new object of the entity model in your code in every method. Or you can read more information in the following answer to the same question in the MSDN, Click Here

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