title: Apex merging not working - Entity is deleted?
body: <p>I'm receiving this error and the merge of the two contacts is not working. Any help appreciated.</p>
  
  <p>Here is one of the errors I'm receiving in the logs: "23:10:48:243 EXCEPTION_THROWN [14]|System.DmlException: Update failed. First exception on row 0 with id a0A1a0000095ZDxEAM; first error: ENTITY_IS_DELETED, entity is deleted: []"</p>
  
  <p>Here is my class for merging (the custom fields are contact lookups):</p>
  
  <pre><code>public class BatchMerge implements Database.Batchable&lt;sObject&gt; {
      public Database.QueryLocator start(Database.BatchableContext context) {
          return Database.getQueryLocator([SELECT Contact_to_Merge_Into__c, Contact__c FROM Contact_Merge_Record__c]);
      }
      public void execute(Database.BatchableContext context, Contact_Merge_Record__c[] records) {
          for(Contact_Merge_Record__c record: records) {
              try {
                  Database.merge(new Contact(Id=record.Contact_to_Merge_Into__c), record.Contact__c);
                  record.Merge_Status__c = 'Success';
              } catch(exception e) {
                  record.Merge_Status__c = 'Failed';
              }
          }
          update records;
      }
      public void finish(Database.BatchableContext context) {
      }
  }
  </code></pre>