title: Autofac Scoping Of Unit Of Work In MVC3 With Entity Framework
body: <p>We have a standard "chain" of modules that MVC3 controller creates and calls (directly or indirectly) - "MyController" -> "MyService" -> "MyRepository" -> "MyUnitOfWork"</p>
  
  <p>The modules are registered in App_Start as following:</p>
  
  <pre><code>var builder = new ContainerBuilder();
  
  builder.RegisterType&lt;MyRepository&gt;().AsImplementedInterfaces().InstancePerHttpRequest();
  builder.RegisterType&lt;MyUnitOfWork&gt;().AsSelf().InstancePerHttpRequest();
  builder.RegisterType&lt;MyService&gt;().AsImplementedInterfaces().InstancePerHttpRequest();
  
  IContainer container = builder.Build();
  DependencyResolver.SetResolver( new AutofacDependencyResolver( container ) );
  </code></pre>
  
  <p>When we try to perform multiple calls to the service from the controller in parallel, we're getting exceptions in EF4 (we use DbContext as a base class for UoW).</p>
  
  <p>What would be a correct scoping of the modules to make parallel calls to service in the context of the same HttpRequest?</p>
  
  <p>Thank you :)</p>