I'm setting up a Worker Service, and I need to pass a connection string to UseSqlServerStorage().
IHost host = Host.CreateDefaultBuilder(args)
.ConfigureServices(services =>
{
services.AddHostedService<WorkerService>();
services.AddHangfire(configuration => configuration
.UseSqlServerStorage("NEEDS CONNECTION STRING HERE!"));
services.AddHangfireServer();
})
.UseWindowsService()
.Build();
In order to do that, I need to call ConfigurationManager.GetConnectionString(). But how can I access ConfigurationManager here?