I have WebApi project that has reference on other my project DataAccess.
In DataAccess I have registered IDbSessionManager as
builder.RegisterType<DbSessionManager>().As<IDbSessionManager>();
In WebApi project I want to override this registration in next way:
builder.RegisterType<DbSessionManager>().As<IDbSessionManager>().InstancePerRequest();
If I add both registrations, then Autofac throws exception
No scope with a tag matching 'AutofacWebRequest' is visible from the scope in which the instance was requested.
It can be solved if I remove registration from WebApi project or change it in this way:
builder.RegisterType<DbSessionManager>().As<IDbSessionManager>().SingleInstance();
But I need that IDbSessionManager was resolved per request.
Previously there was one solution to update container but now Update method are deprecated.
Is there any other way of doing this? Maybe using extension method like OnlyIf ?