I have been using Autofac for a while and I find it really useful in dynamic resolving services in runtime and also the lifetimeScope feature. Moreover, I find the Autofac modules more cleaner way of registering services for DI over registering them in startup/extensions. Now Im migrating few projects from .net-core-3.1 to net6 and found IServiceProvider
has the ability to resolve services dynamically in runtime. Also since IServiceProvider
wraps IServiceScopeFactory
it has the ability to create disposable scopes as well. Im using few dependencies that must be registered through IServiceCollection
like MassTransit. In that case I think sticking to one IoC container would be good for the long run.
Should I completely remove Autofac and stick with IServiceCollection?
Tried going through many official documentations. Just trying to find the best solution out of the two ways.