Nested DbContext due to method calls - Entity Framework

后端 未结 4 1714
广开言路
广开言路 2020-12-13 04:21

In the following case where two DbContexts are nested due to method calls:

public void Method_A() {
    using (var db = new SomeDbContext()) {
        //...d         


        
4条回答
  •  自闭症患者
    2020-12-13 04:53

    You can alter your code by passing to Method_B the context. If you do so, the creation of the second db call SomeDbContext will not be necessary.

    there a question an answer in stackoverflow in this link Proper use of "Using" statement for datacontext

提交回复
热议问题