title: Slick: Codegen foreign key references
body: <p>I am using <a href="http://slick.typesafe.com/doc/2.1.0-M2/code-generation.html" rel="nofollow">slick 2.x's codegen</a> feature to generate Scala models from database schema. However, is it possible to traverse foreign key constraints to generate related models e.g. if I have this schema</p>
  
  <pre><code>CREATE TABLE people(id INT PRIMARY KEY AUTO INCREMENT, name VARCHAR(31));
  CREATE TABLE dogs(name VARCHAR(31), ownerId INT FOREIGN KEY people(id));
  </code></pre>
  
  <p>I get the following models from slick:</p>
  
  <pre><code>case class PeopleRow(id: Int, name: String)
  case class DogsRow(name: String, ownerId: Int)
  </code></pre>
  
  <p>But, what I actually want is this:</p>
  
  <pre><code>case class PeopleRow(id: Int, name: String)
  case class DogsRow(name: String, owner: PeopleRow)
  </code></pre>
  
  <p>or even better:</p>
  
  <pre><code>case class PeopleRow(id: Int, name: String) {
    def dogs: List[DogsRow]   // return items from dogs table that has this.id as ownerId
  }
  
  case class DogsRow(name: String, ownerId: People) {
    lazy val owner: People  // lazy on-demand or, can be a def too
  }
  </code></pre>
  
  <p>Is there anyway to override the slick codegen to do this?</p>