I know in old .NET we used to have Autofac and injector net ?
But why .NET Core still maintaing Autofac?
https://autofac.readthedocs.io/en/latest/integration/aspnetcore.html
We can dependency Using
addsingleton vs addscoped vs addtransient
Any reason ?
Thanks.
Autofac is a library which existed long before .NET Core so migrating it makes sense at least for the sake of easier migration of projects already using it. Also it is not maintained by Microsoft and/or team developing .NET Core (see the github project).
Autofac supports more features than build in DI, which misses things like (see the docs):
The built-in service container is designed to serve the needs of the framework and most consumer apps. We recommend using the built-in container unless you need a specific feature that it doesn't support, such as:
- Property injection
- Injection based on name (.NET 7 and earlier versions only. For more information, see Keyed services.)
- Child containers
- Custom lifetime management
Func<T>
support for lazy initialization- Convention-based registration