| name | migrating-autofac-to-dotnet-di |
| description | Removes Autofac entirely and migrates to ASP.NET Core built-in DI by mapping container registrations, lifetimes, and module patterns. Use when upgrading .NET projects that reference Autofac packages, when converting ContainerBuilder registrations, or when replacing Autofac modules with IServiceCollection extensions. Triggers for "replace Autofac", "remove Autofac", "migrate to built-in DI", "convert dependency injection", Autofac.Extensions.DependencyInjection, RegisterType, InstancePerLifetimeScope, and ContainerBuilder references in C# or VB.NET projects.
|
| metadata | {"traits":".NET|CSharp|VisualBasic|DotNetCore","discovery":"lazy"} |
Autofac to ASP.NET Core DI Migration
Overview
Converts Autofac DI registrations to ASP.NET Core's built-in IServiceCollection pattern. The built-in container covers most registration scenarios; assembly scanning requires the Scrutor NuGet package.
Related skill: If the goal is to keep Autofac but modernize its integration with ASP.NET Core, use integrating-autofac-with-dotnet instead.
Verification
Before starting, confirm the project actually uses Autofac. Search for Autofac NuGet references and ContainerBuilder usage. If none found, inform the user there is nothing to migrate.
Workflow
Migration Progress:
- [ ] Step 1: Locate Autofac registrations
- [ ] Step 2: Document all registrations
- [ ] Step 3: Remove Autofac code
- [ ] Step 4: Remove Autofac packages
- [ ] Step 5: Create registration helper
- [ ] Step 6: Wire into Program.cs
- [ ] Step 7: Build and verify
Step 1: Locate Autofac registrations
Find ContainerBuilder setup code (check , , or Autofac module classes).