title: How to get nested Foreign Key attribute using Entity Framework
body: <p>I have a question regarding foreign key in entity framework(EF4).</p>
  
  <p>Lets say i have classes :</p>
  
  <pre><code>public class E1
  {
     public int Id{get;set;}
     Public string name{get;set;}
  }
  public class E2
  {
     [ForeignKey("e1")]
     public int E1Id{get;set;}
  
     [ForeignKey("E1Id")]
     public E1 e1{get;set;}
  
  }
  public class E3
  {
     [ForeignKey("e2")]
     public int E2Id{get;set;}
  
     [ForeignKey("E2Id")]
     public E2 e2{get;set;}
  }
  public class E4
  {
  }
  </code></pre>
  
  <p>respectively and i suppose i want to access the attribute of <code>class E1</code> in <code>class E4</code> by calling  via object of <code>E3</code> (which internally calls <code>E2</code>) as well as <code>E2</code> calling <code>E1</code> as shown above but when i try to access the attribute of <code>E1</code> it throws <code>object null reference</code> exception so whats the possible way to get the attributes of <code>E1</code>?</p>