title: IRepository, IService, Unity in an ASP.NET MVC Application, reference question
body: <p>I'm new to Unity, but this question is more generic to IoC, and I’m pretty new to implementing IoC as a whole.  I have VS2010 solution with this project structure (simplified slightly):</p>
  
  <ul>
  <li>Business Objects – Folder
  <ul>
  <li>DomainModel (Class Lib prj.) – Entity Framework 2 POCO entities</li>
  </ul></li>
  <li>Data Layer – Folder
  <ul>
  <li>DataAccess (Class Lib prj.) – EF2 EDMX</li>
  <li>Repository (Class Lib prj.) – IRepository interface &amp; repository concrete implementations</li>
  </ul></li>
  <li>Presentation Layer – folder
  <ul>
  <li>WebUI – MVC Project</li>
  </ul></li>
  <li>Service Layer
  <ul>
  <li>Service (Class Lib prj.) – IService interface and service (façade pattern) concrete implementations</li>
  </ul></li>
  </ul>
  
  <p>All project reference the DomainModel project.</p>
  
  <p>Repository references the DataAccess project.</p>
  
  <p>Service Layer references the Repository project.</p>
  
  <p>WebUI references the Service project &amp; the Unity assemblies.</p>
  
  <p>I have Unity configured to inject all my service types correctly in the WebUI (global.asax via a custom UnityControllerFactory.cs).  But how do I configure Unity in the service layer to inject the repository objects?</p>
  
  <p>I DON’T want to reference the Repository project from the WebUI to ensure during development no one shortcuts and bypass the Service layer.</p>
  
  <p>Couple Ideas I have (not sure if it will solve it):</p>
  
  <ol>
  <li>Move the IRepository Interfaces into the DomainModel and add the Unity.RegisterType&lt;> calls for the IRepository</li>
  <li>Set up Unity configuration in the Web.config</li>
  </ol>
  
  <p>Any direction would be greatly appreciated, specifically to how to configure Unity for the service layer / Repository, but also in general about the project.</p>