microsoft/upgrade-agent-plugins/integrating-autofac-with-dotnet
Claude Code and agent skill by microsoft/upgrade-agent-plugins
- vendor
Checking that the SKILL.md file is still in the repository.
Migrates Autofac dependency injection configuration from ASP.NET Framework to ASP.NET Core's hosting model while keeping Autofac as the DI container. Use when upgrading projects that use Autofac, migrating Global.asax.cs or Startup.cs DI setup to Program.cs, or integrating AutofacServiceProviderFactory with the generic host. Triggers for Autofac container registration, UseServiceProviderFactory, ContainerBuilder migration, and DependencyResolver removal.
Install
npx vskill@latest install microsoft/upgrade-agent-plugins/integrating-autofac-with-dotnetSKILL.md
The same SKILL.md was published earlier as microsoft/upgrade-agent-plugins/integrating-autofac-with-dotnet.
Register Autofac with ASP.NET Core
Overview
When migrating from ASP.NET Framework to ASP.NET Core, Autofac integration changes significantly. The old pattern of manually building a container and setting DependencyResolver is replaced by registering Autofac as the host's service provider factory. This ensures Autofac participates in the standard DI lifecycle rather than bypassing it.
Related skill: If the goal is to remove Autofac entirely and replace with built-in DI, usemigrating-autofac-to-dotnet-diinstead.
Workflow
Step 1: Verify Autofac usage
- Confirm the project uses Autofac for dependency injection. If not, skip — inform the user there is nothing to do.
- Check if
Program.csalready callsUseServiceProviderFactory(new AutofacServiceProviderFactory()). If so, verify the container configuration is correct and skip remaining steps.
Step 2: Install required package
Install Autofac.Extensions.DependencyInjection with a version matching the project's target framework. This package provides the AutofacServiceProviderFactory bridge between Autofac and the .NET hosting model.
Step 3: Locate and extract existing registrations
Search for Autofac registration code that builds a container — typically in Global.asax.cs, Startup.cs, or other top-level initialization classes. Record all ContainerBuilder registrations and module registrations before removing that code.
Why remove first? The old code manually callsbuilder.Build()and sets aDependencyResolver, which conflicts with the host-managed container lifecycle in ASP.NET Core.
Step 4: Register Autofac as service provider factory
Add to Program.cs:
Step 5: Migrate container registrations
Move all extracted registrations into a ConfigureContainer block in Program.cs:
Omit any calls to builder.Build() or resolver setup — the host handles container building automatically.
Step 6: Remove obsolete integration code
Delete ASP.NET Framework-specific Autofac wiring such as:
DependencyResolver.SetResolver(new AutofacDependencyResolver(container));GlobalConfiguration.Configuration.DependencyResolver = resolver;- Manual
ContainerBuilder.Build()calls in startup code
Step 7: Validate
- Build the project and fix any compilation errors.
- Verify services resolve correctly at runtime.
Example
Before (Global.asax.cs or Startup.cs):
After (Program.cs):
Success Criteria
Autofac.Extensions.DependencyInjectionpackage installedUseServiceProviderFactoryconfigured in Program.cs- All registrations and modules migrated to
ConfigureContainerblock - Obsolete
DependencyResolverand manualBuild()calls removed - Project compiles and services resolve correctly at runtime
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files. Certified 25 Oct 2026.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingplugins/upgrade-agent/upgrade/dotnet/skills/lazy/libraries/integrating-autofac-with-dotnet/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/microsoft/upgrade-agent-plugins/integrating-autofac-with-dotnet)