的DbContext不包含定义“刷新” [英] dbcontext does not contain a definition for 'Refresh'
问题描述
我与实体框架代码第一个工作,我得到下面的编译错误。
的DbContext不包含刷新的定义。我看到,其中正在使用的刷新方法的许多例子。但是,当我刷新方法添加到我的DbContext我得到一个complilation错误。我使用下面的命名空间。
使用System.Data这;
使用System.Data.Entity的;
使用将System.Data.Linq;
I'm working with the entity framework code first and am getting the following compilation error. dbcontext does not contain a definition for 'Refresh'. I have seen many examples where the Refresh method is being used. But when i add the Refresh method to my dbcontext I get a complilation error. I'm using the following namespaces. using System.Data; using System.Data.Entity; using System.Data.Linq;
我失去之一。在adavance我想看看它,但没有找到该命名空间。
Am i missing one. I tried to look it up but did not find the namespace.
感谢,
约翰
推荐答案
的DbContext确实没有刷新()方法。
DbContext does indeed not have a Refresh() method.
您看到的很可能使用的 ObjectContext.Refresh()。
The examples you saw were probably using ObjectContext.Refresh().
您可以得到一个从其他:
You can get one from the other:
db = new MyDbContext())
...
var ctx = ((IObjectContextAdapter)db).ObjectContext;
ctx.Refresh();
这问题有更多的细节和差异。
This question has more about the details and differences.
这篇关于的DbContext不包含定义“刷新”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!