title: One-to-many relationship returns null in Entity Framework
body: <p>I am trying to make relationships in Entity Framework and my SQL Server with Fluent API. Here's how I insert:</p>
  
  <pre><code>CREATE TABLE Product (
      id INT PRIMARY KEY NOT NULL IDENTITY(1,1),
      name VARCHAR(255)
  );
  
  CREATE TABLE OrderLine (
      id INT PRIMARY KEY NOT NULL IDENTITY(1,1),
      productId INT NOT NULL,
      FOREIGN KEY (productId) REFERENCES Product(id)
  );
  </code></pre>
  
  <p>Now, <code>product</code> has many <code>orderLine</code>s, but does not know them and does not need to know them. We don't need to pick a single product and count the amount of orderlines, for example. Here's how it looks:</p>
  
  <pre><code>public class Product {
      public int id { get; set; }
  
      public string name { get; set; }
  
      public ICollection&lt;OrderLine&gt; orderLines { get; set; } //not needed but we'll have it anyway
  }
  </code></pre>
  
  <p><br /></p>
  
  <pre><code>public class OrderLine {
      public int id { get; set; }
  
      public int productId { get; set; }
  
      public Product product { get; set; }
  }
  </code></pre>
  
  <p>According to <a href="http://www.entityframeworktutorial.net/code-first/configure-one-to-many-relationship-in-code-first.aspx" rel="nofollow noreferrer">entityframeworktutorial.net</a> this could should work:</p>
  
  <pre><code>modelBuilder.Entity&lt;Product&gt;()
      .HasMany&lt;OrderLine&gt;(s =&gt; s.orderLines)
      .WithRequired(s =&gt; s.product)
      .HasForeignKey(s =&gt; s.productId);
  </code></pre>
  
  <p>However, <code>product</code> is simply null when I try to pull it out of the database. Is this not a one-to-many relationship? I'm not quite sure where I went wrong.</p>