Recently we upgraded to EF6 hopping to take advantage of its async call in our webapi controller but after some online reading i can to know
- EF6 async call is not thread safe
While thread safety would make async more useful it is an orthogonal feature. It is
unclear that we could ever implement support for it in the most general case, given that
EF interacts with a graph composed of user code to maintain state and there aren't
easy ways to ensure that this code is also thread safe.
but same thing is conveyed in this question EF Data Context - Async/Await & Multithreading
but when i looked at samples from MS http://msdn.microsoft.com/en-us/data/jj819165.aspx i am confused , because if i look at answers provided in stackoverflow question it seems currently we dont have any solution/pattern to implement it thread safe with single db context?
So my question is again how to achieve
var dbContext = new DbContext();
var something = await dbContext.someEntities.FirstOrDefaultAsync(e => e.Id == 1);
var morething = await dbContext.someEntities.FirstOrDefaultAsync(e => e.Id == 2);
is a correct way with thread safe feature?