title: Difference between DbSet<T> property and Set<T>() function in EF Core?
body: <p>Given this kind of context:</p>
  
  <pre><code>public class FooContext : DbContext 
  {
      public FooContext(DbContextOptions&lt;FooContext&gt; opts) : base(opts)
      { }
  
      public DbSet&lt;Bar&gt; Bars { get; set; }
  }
  </code></pre>
  
  <p>I can get to a <code>Bar</code> in two ways:</p>
  
  <pre><code>fooContext.Bars.Add(new Bar()); // Approach 1
  </code></pre>
  
  <p>or</p>
  
  <pre><code>fooContext.Set&lt;Bar&gt;().Add(new Bar()); // Approach 2
  </code></pre>
  
  <p>What is the difference between the two approaches?</p>
  
  <p>I've tried to answer my own question by:</p>
  
  <ul>
  <li>Inspecting the intellisense for both (only tells me that <code>Set&lt;T&gt;()</code> also creates a <code>DbSet&lt;T&gt;</code>)</li>
  <li><a href="https://www.google.nl/search?q=EF+Core+Set&lt;T&gt;+vs+property" rel="noreferrer">Googling for "EF Core Set vs property"</a> but that doesn't seem to be the 'right' query</li>
  <li><a href="https://www.google.nl/search?q=DbSet+site%3Ahttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fef%2Fcore%2F" rel="noreferrer">Google for <code>DbSet&lt;T&gt;</code> specifically on the docs urls</a> but no relevant results here either it seems</li>
  <li>Reading the intro of <a href="https://docs.microsoft.com/en-us/ef/core/api/microsoft.entityframeworkcore.dbset-1" rel="noreferrer">the <code>DbSet&lt;T&gt;</code> docs</a> which just suggests that you can get a set through either of the two methods (not if there is or isn't a difference)</li>
  <li>Read <a href="https://docs.microsoft.com/en-us/ef/core/api/microsoft.entityframeworkcore.dbcontext.set" rel="noreferrer">the <code>Set&lt;T&gt;()</code> docs</a> which has no relevant info</li>
  </ul>
  
  <p>But I could not find any good explanation about which of the two is used for which purpose. What is the difference? Or perhaps more importantly: where and how should I be able to find this in the docs?</p>