title: Database First + EF + POCO; T4 Code Generation?
body: <p>I'm using a DB first approach, using Entity Framework and I've just read this article about <a href="http://blogs.msdn.com/b/adonet/archive/2009/05/21/poco-in-the-entity-framework-part-1-the-experience.aspx" rel="nofollow"><strong><code>POCO</code> In EF</strong></a>. Now: How can I generate the POCO templates directly from the database?</p>
  
  <pre><code>namespace My.Domain
  {
      public class Entity
      {
          public virtual long EntityId { get; set; }
          public virtual string Example { get; set; }
          public virtual long NextId { get; set; }
          public virtual bool Lame { get; set; }
      }
  }
  </code></pre>
  
  <p>In fact I would like it very much to being able to generate the same stuff I generate manually, in just one step:</p>
  
  <ul>
  <li>Add the <code>ObjectSet</code> for each table to the <code>ObjectContext</code>, each with it's field, property getter and creation.</li>
  <li>Create <code>POCO</code> entities, preferrably  in another project, with all the property mappings including relationships, with properties marked as virtual to enable proxying, and obviously in a namespace of my choice.</li>
  </ul>
  
  <p>Is there a "simple" way to accomplish this using T4 templates, or is there some other tool available to do just this? Perhaps some kind of <code>Custom Tool</code> instead of the one that comes with EF, but that is <code>POCO</code>-oriented?</p>