title: How to create One-to-many relationship in Entity Framework 4.1 using Code First and Data Annotations?
body: <p>I'm struggling with creating a simple one-to-many relationship using Code First in EF. I want it to generate daatabase for me but couldn't figure out how to write these classes so it would create it.</p>
  
  <p>I have these classes:</p>
  
  <pre><code>public class Book
  {
      public int ID { get; set; }
      public string Author { get; set; }
      public ICollection&lt;Page&gt; Pages { get; set; }
  }
  
  public class Page
  {   [Key]
      public int BookID { get; set; }
  
      public  Book Book { get; set; }
  
      public string OtherField { get; set; }
  }
  </code></pre>
  
  <p>But I get error while it ties to generate database:</p>
  
  <blockquote>
    <p>Unable to determine the principal end of an association between the types 'MvcApplication1.Models.Page' and 'MvcApplication1.Models.Book'. The principal end of this association must be explicitly configured using either the relationship fluent API or data annotations</p>
  </blockquote>
  
  <p>I just want to generate two simple tables, "Book" with ID as primary key, and Page with BookID as a primary and foreign key. It really should be simple but I just can't figure it out.</p>