How to Dispose DbContext(or object) in asp.net mvc3 App when Ninject is used as dependency resolver

后端 未结 2 761
猫巷女王i
猫巷女王i 2021-02-06 15:23

For this Demo I have created a fake Database+repository as below

Fake Db + Repository

 public interface IDemoRepository
    {
        string[] GetUser         


        
2条回答
  •  星月不相逢
    2021-02-06 15:58

    Make sure that your repository is bound to the request scope in Ninject if you want it to be disposed:

    kernel.Bind().To().InRequestScope();
    

提交回复
热议问题