c# - Await is disposing DbContext - The ObjectContext instance has been disposed -


i have following in async method has instance of dbcontext passed it:

 var userids = await getuserids(db); 

with getuserids:

    private async task<list<int>> getuserids(appcontext db)     {         var items = await db.items.where(s => s.isvalid).distinct().tolistasync(); // simplified         return items;     } 

but get:

{"the objectcontext instance has been disposed , can no longer used operations require connection."}

i can force run removing await , tolistasync, that's bandaid. why context getting disposed?

i suspect caller of getuserids method disposing context before operation completes. sure you're awaiting returned task before disposing context?


Comments

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -