private void DoWord(object state)
 {
     using (var scope = Services.CreateScope())
     {
         var context = scope.ServiceProvider.GetRequiredService <ApplicationDbContext>();
         var message = "ConsumeScopedService. Received message at " + DateTime.Now.ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss");
         var log     = new HostedServiceLogs()
         {
             Message = message
         };
         context.HostedServiceLogs.Add(log);
         context.SaveChanges();
     }
 }
 private void DoWork(object state)
 {
     using (var scope = Services.CreateScope())
     {
         ApplicationDbContext context = scope.ServiceProvider.GetRequiredService <ApplicationDbContext>();
         string            message    = "ConsumedService: Recived message at: " + DateTime.Now.ToString("dd/MM/yyyy hh:mm:ss");
         HostedServiceLogs log        = new HostedServiceLogs()
         {
             Message = message
         };
         context.HostedServiceLogs.Add(log);
         context.SaveChanges();
     }
 }