title: EF 4.1 - Model Relationships
body: <p>I'm trying to create a quick ASP.NET MVC 3 application using the RC version of EF 4.1. I have two models:</p>
  
  <pre><code>public class Race
  {
      public int RaceId { get; set; }
      public string RaceName { get; set; }
      public string RaceDescription { get; set; }
      public DateTime? RaceDate { get; set; }
      public decimal? Budget { get; set; }
      public Guid? UserId { get; set; }
      public int? AddressId { get; set; }
  
      public virtual Address Address { get; set; }
  }
  </code></pre>
  
  <p>and </p>
  
  <pre><code>public class Address
  {
      public int AddressId { get; set; }
      public string Street { get; set; }
      public string StreetCont { get; set; }
      public string City { get; set; }
      public string State { get; set; }
      public string ZipCode { get; set; }
  
      public virtual Race Race { get; set; }
  }
  </code></pre>
  
  <p>I get the following error when trying to insert a new Race:</p>
  
  <blockquote>
    <p>Unable to determine the principal end
    of an association between the types
    'rcommander.Models.Race' and
    'rcommander.Models.Address'. The
    principal end of this association must
    be explicitly configured using either
    the relationship fluent API or data
    annotations.</p>
  </blockquote>
  
  <p>Shouldn't it recognize RaceId as the primary key of the Races table and AddressId as the FK to the Addresses table automatically? Am I missing something?</p>
  
  <p>Thanks!</p>