title: Entity Framework: When to use Set<>
body: <p>I'm trying understand the basics of Entity Framework and I have a question about the Set&lt;> method on DbContext. I am using a database first model for the following question.</p>
  
  <p>Let's say I have an ActivityLog database which amongst other things I can use to pull out a message (NLog message, for example). I could write some code to pull out all messages like this:</p>
  
  <pre><code>using (var entities = new ActivityLogEntities())
      foreach (var log in entities.AcitivityLogs)
          Console.WriteLine(log.Message);
  </code></pre>
  
  <p>However I could also achieve the same thing doing this:</p>
  
  <pre><code>using (var entities = new ActivityLogEntities())
      foreach (var message in entities.Set&lt;ActivityLog&gt;().Select(entity =&gt; entity.Message))
          Console.WriteLine(message);
  </code></pre>
  
  <p>My question is what is the difference between these two statements? When is it more appropriate to use one over the other? Or is this just a matter of personal preference?</p>