title: ASP.NET MVC/Service Layer/Repository/EF4/POCO - Am I thinking right?
body: <p>I have been working on a new ASP.NET MVC application and trying my best to implement the Service Layer/Repository/UOW patter using EF4 and POCO classes.</p>
  
  <p>Help me see if I am understanding this correctly.</p>
  
  <p>Lets say for the sake of keeping this simple, that a client is requesting a view of a Customer.</p>
  
  <p>1) Client requests a view from the <strong>CustomerController</strong>.<br>
  2) The <strong>CustomerController</strong> creates a new <strong>UOW</strong> and a new <strong>CustomerService</strong> passing in the <strong>UOW</strong>.<br>
  3) The <strong>CustomerService</strong> creates a new <strong>Repository(Of Customer)</strong> and passes in the <strong>UOW</strong> it received from the <strong>CustomerService</strong>. This is the layer where you would say maybe something like "Are you allowed to view this customer?"<br>
  4) The <strong>CustomerRepository</strong> handles getting the <strong>POCO</strong> classes from the <strong>EF4</strong>.<br>
  5) The <strong>CustomerRepository</strong> hands the <strong>POCO</strong> classes back to the <strong>CustomerService</strong>, which then hands them back to the <strong>CustomerController</strong>.<br>
  6) The <strong>CustomerController</strong> uses the <strong>POCO</strong> classes to fill the <strong>CustomerViewModel</strong> and then hands the <strong>CustomerViewModel</strong> off to the <strong>CustomerView</strong>.</p>
  
  <p>I am still a little confused on why/where to use AutoMapper???</p>
  
  <p>Any advice on this would be greatly appreciated.</p>