My question is simple, if I perform a read or write within a Task.Run in order to make my method asynchronous, will it work as a normal bit of code would, or is there something within EF that bans this practice?
For example:
await Task.Run(() =>
{
var data = _context.KittenLog.ToList();
}
I have an uneasy feeling that doing this will open a can of worms, but I can't find anything on google about combining the two.
Well yes, you could. But there is no need to wrap it in a call to Task.Run
since it has native async support, see https://msdn.microsoft.com/en-us/library/jj819165(v=vs.113).aspx#Making it asynchronous
In you case it will become something like:
var data = await _context.KittenLog.ToListAsync(CancellationToken.None);
There a some things to consider. Like the context can only handle one async operation at a time.