title: How to rollback a transaction in Entity Framework
body: <pre><code>string[] usersToAdd = new string[] { "asd", "asdert", "gasdff6" };
  using (Entities context = new Entities())
  {
      foreach (string user in usersToAdd)
      {
          context.AddToUsers(new User { Name = user });
      }
      try
      {
          context.SaveChanges(); //Exception thrown: user 'gasdff6' already exist.
      }
      catch (Exception e)
      {
          //Roll back all changes including the two previous users.
      }
  </code></pre>
  
  <p>Or maybe this is done automatically, meaning that if error occurs, committing changes are canceled for all the changes.
  is it?</p>