Adding Autofac to .NET core 6.0 using the new single file template
I found this Microsoft docs var builder = WebApplication.CreateBuilder(args); builder.Host.UseServiceProviderFactory(new AutofacServiceProviderFactory()); // Register services directly with Autofac here. // Don’t call builder.Populate(), that happens in AutofacServiceProviderFactory. builder.Host.ConfigureContainer<ContainerBuilder>( builder => builder.RegisterModule(new MyApplicationModule())); var app = builder.Build();