Skip to content

Instantly share code, notes, and snippets.

@hd9
Created October 18, 2019 17:41
Show Gist options
  • Save hd9/b6a627797439b26e0dbc01f9f28cbcf7 to your computer and use it in GitHub Desktop.
Save hd9/b6a627797439b26e0dbc01f9f28cbcf7 to your computer and use it in GitHub Desktop.
Accessing Entity Framework context on the background on .NET Core
// Step 2 - Pass it to your background thread
// Source: https://blog.hildenco.com/2018/12/accessing-entity-framework-context-on.html
public async Task<IActionResult> TestAsyncCall(string id)
{
Task.Run(() => BgTask(id, serviceScopeFactory));
return Ok("Thanks, your code will be executed!");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment