title: Entity Framework Code First One to One Relationship
body: <p>I have the following two models</p>
  
  <pre><code>public class Account
  {
       public int Id { get; set; }
       public string Name { get; set; }
       public int CurrentPeriodId { get; set; }
  
       [ForeignKey("CurrentPeriodId")]
       public virtual Period CurrentPeriod { get; set; }
  
       public virtual ICollection&lt;Period&gt; Periods { get; set; }
  }
  
  public class Period
  {
       public int Id { get; set; }
       public int AccountId { get; set; }
       public DateTime StartDate { get; set; }
       public DateTime EndDate { get; set; }
  
       public virtual Account Account { get; set; }
  }
  </code></pre>
  
  <p>And I am trying to run the following query:</p>
  
  <pre><code>from p in context.Periods
  where p.AccountId == accountId &amp;&amp;
        p.Id == p.Account.CurrentPeriodId
  select p.StartDate
  </code></pre>
  
  <p>And I get a sql exception saying "Invalid column name Account_AccountId".</p>
  
  <p>I know I could approach this from the Account side and do something like</p>
  
  <pre><code>from a in context.Accounts
  where a.Id == id
  select a.CurrentPeriod.StartDate
  </code></pre>
  
  <p>But I would like to know how to setup the relationship to get the other query to work.  What am I missing?</p>