Solving “The ObjectContext instance has been disposed and can no longer be used for operations that require a connection” InvalidOperationException

前端 未结 7 2220
再見小時候
再見小時候 2020-11-22 06:38

I am trying to populate a GridView using Entity Frameworkm but every time I am getting the following error:

\"Property accessor \'LoanPro

7条回答
  •  梦如初夏
    2020-11-22 07:05

    If you're using ASP.NET Core and wonder why you get this message in one of your async controller methods, make sure you return a Task rather than void - ASP.NET Core disposes injected contexts.

    (I'm posting this answer as this question is high in the search results to that exception message and it's a subtle issue - maybe it's useful to people who Google for it.)

提交回复
热议问题