title: Entity Framework 5 with MVC4
body: <p>I am building a website with a rather complex <code>SQL</code> database.<br/>
  I made a <code>Query</code> class, which holds multiple primitive fields (which all work fine) and also multiple <code>List&lt;SomeType&gt;</code>. <code>SomeType</code> is also defined under the <code>Models</code> folder in my solution. It also holds single instances of <code>SomeType</code>. Then, I made a <code>QueryDBContext</code> class which inherits <code>DbContext</code>.<br/><br/></p>
  
  <p>I have a <code>Generate</code> function which receives a string and creates a fully formed <code>Query</code> instance. If I immediately send it to my <code>View</code> - it works fine. But if I store it in my <code>DB</code> - only the primitive values are kept, and the reference types (both <code>Lists&lt;SomeType&gt;</code> and <code>SomeType</code>) are <code>null</code>.<br/><br/></p>
  
  <p>I believe the problem is that EF doesn't support reference types - or maybe I need something special for this case?<br/>
  Here's <code>Query</code></p>
  
  <pre><code>public class Query
  {
      [Key]
      public int id { get; set; }
  
      public SomeType Base { get; set; }
      public List&lt;SomeType&gt; Derived { get; set; }
      //more of these
  
      public string SmallGraphImage { get; set; }
      public string MediumGraphImage { get; set; }
      public string LargeGraphImage { get; set; }
  }
  public class QueriesDBContext : DbContext
  {
      public DbSet&lt;Query&gt; Queries { get; set; }
  }
  </code></pre>
  
  <p>Here's <code>SomeType</code></p>
  
  <pre><code>public class SomeType
  {
      [Key]
      public int id { get; set; }
      public string ExpandedOutForm { get; set; }
      public string ExpandedInForm { get; set; }
      //more strings
  }
  </code></pre>
  
  <p><br/>Note: The database works fine for primitives. For developing purposes, I made a <code>Controller</code> which deletes &amp; rebuilds the database for each modification. I also tried replacing <code>List</code> with <code>IList</code>.<br/><br/></p>
  
  <p>If EF doesn't support reference types, what should I do? Will it work on <code>structs</code> ? How can I store <code>Lists</code> inside a database entry? (Yeah, I could store it in another table with its ID - but I believe EF has a more elegant solution for this)</p>