Registering IoC in a Bounded Context scenario

Sep 24, 2014 at 11:41 AM
I have an app using the IObjectState in my entities (got the idea from Julie Lerman). I really like your framework implementation and had to take advantage. I'm using it with Bounded Contexts and I'm using Autofac for IoC registration in an API.

When trying to register a second context with its services in Autofac, it throws an error. Problem is trying to register multiple DbContexts with same IDataContextAsync.

I tried duplicating it in this solution by adding a bounded context. I added a copy of NorthwindContext to NorthwindContext2 and tried registering it in Unity.
  • .RegisterType<IDataContextAsync, NorthwindContext2>(new PerRequestLifetimeManager())
    When trying to access the Customer View, an error is thrown.
Is it possible to register multiple contexts in Unity and associate the IRepositories and IServices registration to a specific context registration?

Thank you in advance,
Ronnie
Sep 24, 2014 at 3:57 PM
Marked as answer by ronniek on 9/27/2014 at 3:01 AM