Is it possible to resolve an instance of ISettingsService
from the ConfigureServices
method in Startup(.cs) - webapplication?
I've implemented a SettingsService
which is able to retrieve the database connectionstring from an external source (secure credentials store). Within the ConfigureServices I need an instance of the ISettingsService
in order to get the connectionstring and pass it to the services.AddSqlServer<MyDbContext>(connectionstring)
method.
While creating the instance (using var provider = services.BuildServiceProvider(); var settings = provider.GetService<ISettingsProvider>()
;) Visual Studio displays the next error:
Another developer posted a similar question on StackOverflow and the answer provides a solution in case of AddSingleton/ AddTransient. What is the correct way to apply it on the AddSqlServer call? Or could you provide another solution to avoid the warning/ error message?