Is Disposing of Entity Framework context object required

后端 未结 5 1515
臣服心动
臣服心动 2021-02-07 09:39

We are using entity framework for communication with database in our WCF service methods, recently we run the code review tool on our service code. As usual we got many review p

5条回答
  •  深忆病人
    2021-02-07 10:08

    I think the best approach is coding it within a using statement

    using(var cx = new DbContext())
    {
      //your stuff here
    }
    

    so it got automaitaclly disposed

提交回复
热议问题