The implementation AddDbContext simply registers the context itself and its general dependencies in the DI. Instead of calling AddDbContextit, it is completely legal to manually register your DbContext:
services.AddTransient<FooContext>();
Alternatively, you can use the factory method to pass parameters (this is the answer to the question):
services.AddTransient<FooContext>(provider =>
{
var anyOtherClass = provider.GetService<AnyOtherClass>();
return new FooContext(foo, bar);
});
PS, , DbContextOptionsFactory DbContextOptions DbContext, .