var conn = services.FirstOrDefault(descriptor => descriptor.ServiceType == typeof(IDbConnection));
if (conn is null)
{
throw new Exception("NpgsqlConnection is not registered.");
}
services.Remove(conn);
services.AddScoped<IDbConnection>(
_ => new NpgsqlConnection(_postgreSqlContainer.GetConnectionString())
);
var conn = services.FirstOrDefault(descriptor => descriptor.ServiceType == typeof(IDbConnection));
if (conn is null)
{
throw new Exception("NpgsqlConnection is not registered.");
}
services.Remove(conn);
services.AddScoped<IDbConnection>(
_ => new NpgsqlConnection(_postgreSqlContainer.GetConnectionString())
);