'How to access DBContext inside Task.Run?

I was trying to access the DBContext inside a Task.Run call and it gives me an error.

DryIoc.ContainerException: 'Scope disposed{no name, Parent={no name}} is disposed and scoped instances are disposed and no longer available.'

For the example code, please check my github repo https://github.com/khertg/EFCoreParallelTest

What am I doing wrong in this part of the code https://github.com/khertg/EFCoreParallelTest/blob/4329b172695de57ee4cb921396f18b36df355454/FunctionApp/Function1.cs#L85?

Are there any alternatives ?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source