title: Deleting and then adding a new identical entity throws an error
body: <p>I have a model called a DeviceAccount. It is a join table that allows me to create many to many relationships.</p>
  
  <p>I have a function that creates a new DeviceAccount by handing it an account &amp; a device to join. See here:</p>
  
  <pre><code>var createDeviceAccount = function (account, device) {
          var initialValues = {
              account: account,
              device: device
          };
          return manager.createEntity(entityNames.deviceAccount, initialValues);
      };
  </code></pre>
  
  <p>I have a function to delete a DeviceAccount. See here:</p>
  
  <pre><code>var deleteDeviceAccount = function (account, device) {
          var baseQuery = entityQuery.from('DeviceAccounts');
          var p1 = new breeze.Predicate('device', 'eq', device);
          var p2 = new breeze.Predicate("account", "eq", account);
          var modQuery = baseQuery.where(p1.and(p2));
          var results = manager.executeQueryLocally(modQuery);
          results[0].entityAspect.setDeleted();
      };
  </code></pre>
  
  <p>If I locally create, remove, create, remove the same device/account pair there is no problem.
  If I take a device/account pair that exists on the server I can remove it fine, but when I add it again I recieve the following error:</p>
  
  <blockquote>
    <p>Uncaught Error: This key is already attached:
    DeviceAccount:#Test.Models-5:::5</p>
  </blockquote>
  
  <p>If I follow this in more depth I can see that removing a local device changes the entityState to be 'Detached' and if I remove a device that also exists on the server its entityState gets changed to be 'Deleted'. I can't follow much further than this and I was hoping someone could explain why this could be happening?</p>