locked
Error while using AspNet.Identity.EntityFramework (Owin/Katana): The ObjectContext instance has been disposed and can no longer be used for operations that require a connection RRS feed

  • Question

  • Hi,

    I followed all the articles in a series to develop a web api + owin-katana + identity application as described in:

    http://johnatten.com/2015/02/15/asp-net-web-api-understanding-owinkatana-authenticationauthorization-part-iii-adding-identity/

    Source code for this article at: https://github.com/TypecastException/MinimalOwinWebApiSelfHost/tree/auth-identity

    I am using VS 2012. 

    In file: ~/MinimalOwinWebApiSelfHost/MinimalOwinWebApiSelfHost/Models/ApplicationDbContext.cs

    at line no. 67:   var result1 = await manager.CreateAsync(john, "JohnsPassword");

    I keep having this error while seeding the database and I can’t find out why.

    “The ObjectContext instance has been disposed and can no longer be used for operations that require a connection.”
    Any ideas on why?
    Thanks in advance.
    Saturday, July 22, 2017 7:25 AM

All replies

  • Hi,

    I followed all the articles in a series to develop a web api + owin-katana + identity application as described in:

    http://johnatten.com/2015/02/15/asp-net-web-api-understanding-owinkatana-authenticationauthorization-part-iii-adding-identity/

    Source code for this article at: https://github.com/TypecastException/MinimalOwinWebApiSelfHost/tree/auth-identity

    I am using VS 2012. 

    In file: ~/MinimalOwinWebApiSelfHost/MinimalOwinWebApiSelfHost/Models/ApplicationDbContext.cs

    at line no. 67:   var result1 = await manager.CreateAsync(john, "JohnsPassword");

    I keep having this error while seeding the database and I can’t find out why.

    “The ObjectContext instance has been disposed and can no longer be used for operations that require a connection.”
    Any ideas on why?
    Thanks in advance.
    Saturday, July 22, 2017 7:31 AM
  • Hi fusionCoder,

    I have download the project, but I could not find Database Initialize method, which I could not debug the seed method.

    Could you please provide more information about how can I run the seed method from your project.

    Best regards,

    Cole Wu


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    Tuesday, July 25, 2017 9:14 AM