开发者

EF4 CTP5: DbContext inheritance

开发者 https://www.devze.com 2023-02-16 14:28 出处:网络
I have a hierarchical DbContext structure, where I would like a specialized DbContext with its own DbSets to inherit the DbSets of a BaseDbContext.

I have a hierarchical DbContext structure, where I would like a specialized DbContext with its own DbSets to inherit the DbSets of a BaseDbContext.

While accessing the underlying ObjectContext with ((IObjectContextAdapter)this).ObjectContext it takes too long (several minutes) to receive the ObjectContext.

Is there an issue with DbContext in CT5, that getting an ObjectContext from derived DbContext i开发者_开发技巧s not performantly possible?

The structure is: DbContext(EF4) -> myBaseDbContext -> mySpecializedDbContext.

Does anyone have an idea of what´s going on in this scenario? It´s just POCO (CF) with TPC and a little inheritance.


I didn't have performance issues with following and you don't have so many DbSets:

public class MyContext: DbContext
    {       
       //your DbSets<> and other

       public ObjectContext ObjectContext()
       {
          return (this as IObjectContextAdapter).ObjectContext;
       }
    }
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号