DbContext Disposed after first request when using Ninject's InRequestScope()

前端 未结 3 757
借酒劲吻你
借酒劲吻你 2021-02-10 06:17

I am new to both EF and Ninject so forgive me if this does not make sense :)

I have an MVC3 application with the Ninject and Ninject.Web.Common references. I am trying

3条回答
  •  执念已碎
    2021-02-10 06:34

    Set your repositories to be InRequestScope as well. They should dispose after each request.

    Also with MVC you should be using constructor injection to inject your repository into your controller instance as well.

提交回复
热议问题