title: How can I reattach a List to DbSet?
body: <p>When dealing with Code First (EF 4.3), is there a way to work with a <code>List&lt;T&gt;</code> from a <code>DbSet&lt;T&gt;</code>, and then persist the changes to the list?</p>
  
  <p>For example...</p>
  
  <pre><code>class Program {
      static void Main(string[] args) {
          Database.SetInitializer(new DropCreateDatabaseAlways&lt;Context&gt;());
          Database.DefaultConnectionFactory = new SqlCeConnectionFactory("System.Data.SqlServerCe.4.0");
  
          using (Context c = new Context()) {
  
              // Works
              c.Entities.Add(new Entity());
  
              // Doesn't work
              List&lt;Entity&gt; entities = c.Entities.ToList();
              entities.Add(new Entity());
  
              // Somehow attach the new unattached elements?
  
              c.SaveChanges();
  
              Console.WriteLine(c.Entities.Count()); // Prints 1
              Console.ReadLine();
          }
      }
  }
  
  class Context : DbContext {
      public DbSet&lt;Entity&gt; Entities { get; set; }
  }
  
  class Entity {
      public int Id { get; set; }
      public int Foo { get; set; }
  }
  </code></pre>
  
  <p>Is there a way that I can do this?</p>