title: Entity Framework in layered architecture
body: <p>I am using a layered architecture with the Entity Framework. Here's What I came up with till now (All the projects Except UI are class library):  </p>
  
  <ul>
  <li><p><strong>Entities</strong>: The POCO Entities. Completely persistence ignorant. No Reference to other projects. Generated by Microsoft's ADO.Net POCO Entity Generator.  </p></li>
  <li><p><strong>DAL</strong>: The EDMX (Entity Model) file with the context class. (t4 generated). References: <code>Entities</code>  </p></li>
  <li><p><strong>BLL</strong>: Business Logic Layer. Will implement repository pattern on this layer. References: <code>Entities</code>, <code>DAL</code>. This is where the objectcontext gets populated: <code>var ctx=new DAL.MyDBEntities();</code>  </p></li>
  <li><p><strong>UI</strong>: The presentation layer: ASP.NET website. References: <code>Entities</code>, <code>BLL</code> + a connection string entry to entities in the config file (question #2).  </p></li>
  </ul>
  
  <p>Now my three questions: </p>
  
  <ol>
  <li>Is my layer discintion approach correct?</li>
  <li><p>In my UI, I access BLL as follows:<br>
  <code>var customerRep = new BLL.CustomerRepository();<br>
  var Customer = customerRep.GetByID(myCustomerID);</code></p>
  
  <p>The problem is that I have to define the entities connection string in my UI's web.config/app.config otherwise I get a runtime exception. IS defining the entities connectionstring in UI spoils the layers' distinction? Or is it accesptible in a muli layered architecture.  </p></li>
  <li>Should I take any additional steps to perform chage tracking, lazy loading, etc (by etc I mean the features that Entity Framework covers in a conventional, 1 project, non POCO code generation)?</li>
  </ol>
  
  <p>Thanks and apologies for the lengthy question.</p>