What lifestyle should be used to replace PerWebRequest when using the Castle Windsor MS Adapter?
Before dotnet core I would use the PerWebRequest lifestyle for almost all of the components in the container. Now that we are disconnected from IIS modules and http context, I want to ensure my components are being created and disposed when the web requests starts and ends.
container.Register(Component.For<MyEntityFrameworkContext>) .ImplementedBy<MyEntityFrameworkContext>() .LifestyleTransient());
ASP.NET Core has it's own 'scoped' lifecycle, which is 'per request'. See it's documentation: https://docs.microsoft.com/en-us/aspnet/core/fundamentals/dependency-injection
You should do it inside
ConfigureServices method in