title: Declaring DBSet<Type> within DBcontext - Entity Framework Code First
body: <p>When using EF Code First to generate a database, you declare the DB sets within the <code>DbContext</code> class for example..</p>
  
  <pre><code>public DbSet&lt; ProductOption &gt; ProductOptions { get; set; }
  </code></pre>
  
  <p>Now from the reading I have been doing, if you have a related entity in the type <code>ProductOptions</code> you do not need to declare it as EF will look at the dependents and use them to create the required DB tables.</p>
  
  <p>My question is this: Is this recommend practice? And if so how do you then access the related type in code as it does not exist as a data set.</p>
  
  <p>Also this auto-discover feature of EF, does it do it in both directions, i.e if you declare a db set that does not have any related entities inside it, but it is an entity that is in some other entity, will EF find it?</p>
  
  <p>Any clarification is welcome. Thanks</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>Example of what I am saying in terms of not being able to access the Types that are auto discovered is when your seeding data.</p>