Cannot consume scoped service 'MyDbContext' from singleton 'Microsoft.AspNetCore.Hosting.Internal.HostedServiceExecutor'

前端 未结 4 458
遥遥无期
遥遥无期 2021-01-07 18:21

I\'ve build a background task in my ASP.NET Core 2.1 following this tutorial: https://docs.microsoft.com/en-us/aspnet/core/fundamentals/host/hosted-services?view=aspnetcore-

4条回答
  •  迷失自我
    2021-01-07 19:06

    I found the reason of an error. It was the CoordinatesHelper class, which is used in the the background task OnlineTaggerMS and is a Transient - so it resulted with an error. I have no idea why compilator kept throwing errors pointing at MyDbContext, keeping me off track for few hours.

提交回复
热议问题