关闭实体框架 CTP5 中的对象缓存
我无法弄清楚 CTP 5 中实体框架代码优先的内容。它正在缓存对象,但我不希望它这么做。例如,我加载一个加载对象的页面(使用 ASP.NET MVC 站点)。然后我去更改数据库。我重新加载页面,但更改没有反映出来。如果我终止该网站并重新运行它,那么它显然会重新获取。通常对于某种类型,甚至对于特定查询,我如何告诉它始终获取新副本。我认为这可能与 MergeOption 有关,但我无法找到适用于 CTP 5 的示例。谢谢。
I am having trouble figuring out something with the Entity Framework Code First stuff in CTP 5. It is doing caching of objects and I don't want it to. For example, I load a page (working with an ASP.NET MVC site) which loads an object. I then go change the database. I re-load the page and the changes are not reflected. If I kill the site and rerun it then it obviously re-fetches. How do I, either generally for a type, or even for a particular query, tell it to always go get a new copy. I think it might have something to do with MergeOption but I'm having trouble finding examples that work with CTP 5. Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,想通了。有时会从 EF 缓存中提取以下内容:
您可以使用 AsNoTracking() 绕过更改跟踪/缓存内容:
Okay, figured it out. The following will sometimes pull from the EF cache:
You can use AsNoTracking() to bypass the change tracking/caching stuff: