I have common DI usage in my ASP.NET Core application.
public void ConfigureServices(IServiceCollection services)
{
services.AddScoped(sp => new UserContext(new DbContextOptionsBuilder().UseNpgsql(configuration["User"]).Options));
services.AddScoped(sp => new ConfigContext(new DbContextOptionsBuilder().UseNpgsql(configuration["Config"]).Options));
}
In ConfigContext exists method GetUserString which returns connectionString to UserContext.
And I need AddScoped UserContext with connectionString from ConfigContext
when applying to UserContext.