title: When are queries executed on DbContext
body: <p>I am trying to understand the performance impact of having one DbContext class vs multiple when using EF6 framework.</p>
  
  <p>For example, if we have a simple DbContext such as this:</p>
  
  <pre><code>public class MainDbContext : DbContext
  {
      public DbSet&lt;Car&gt; Cars { get; set; }
  
      public void AddCar(Car car)
      {
          Cars.Add(car);
          SaveChanges();
      }
  }
  </code></pre>
  
  <p>Now let us say I have a service that uses the said DbContext in the following way:</p>
  
  <pre><code>public class CarService
  {
      public List&lt;Car&gt; Cars { get; private set; }
      public CarService()
      {
          var dbContext = new MainDbContext();
          Cars = dbContext.Cars.ToList();
      }
  }
  </code></pre>
  
  <p>At what point in time did the DbContext go to the database and retrieved all cars that are stored in the database? Was it when I called <code>var dbContext = new MainDbContext();</code> or was it when I called <code>Cars = dbContext.Cars.ToList();</code>?</p>
  
  <p>If former, if I had a DbContext that contains 100 tables, will all 100 tables be queried when the DbContext is created?</p>