title: Core Data & UIManagedDocument: Can't merge models with two different entities named
body: <p><strong>edit</strong></p>
  
  <p>I have reposted this here: <a href="https://stackoverflow.com/questions/10545613/core-data-uimanageddocument-in-xcode-4-3-cant-merge-models">Core Data &amp; UIManagedDocument in Xcode 4.3: Can&#39;t merge models</a></p>
  
  <p>I managed to get a different error to show.</p>
  
  <p><strong>end of edit</strong></p>
  
  <p>so I am making a Core Data App that used a shared <code>UIManagedDocument</code>. I access this <code>UIManagedDocument</code> using a helper class <code>DocumentHandler</code>.  The hope is that I'll be able to use it like this in another class's <code>viewWillAppear</code>:</p>
  
  <pre><code>if (!self.document) {
          [[DocumentHandler sharedDocumentHandler] performWithDocument:^(UIManagedDocument *document) {
              self.document = document;            
              [self setupFetchedResultsController];
          }]; 
      }
  </code></pre>
  
  <p>`</p>
  
  <pre><code>- (id)init {
      self = [super init];
      if (self) {
          NSURL *url = [[[NSFileManager defaultManager] URLsForDirectory:NSLibraryDirectory inDomains:NSUserDomainMask] lastObject];
          url = [url URLByAppendingPathComponent:@"MyJimDocument"];
  
          self.document = [[UIManagedDocument alloc] initWithFileURL:url];
  
          // Set our document up for automatic migrations
          NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:
                                   [NSNumber numberWithBool:YES], NSMigratePersistentStoresAutomaticallyOption,
                                   [NSNumber numberWithBool:YES], NSInferMappingModelAutomaticallyOption, nil];
          self.document.persistentStoreOptions = options;
  
          // Register for notifications
          [[NSNotificationCenter defaultCenter] addObserver:self
                                                   selector:@selector(objectsDidChange:)
                                                       name:NSManagedObjectContextObjectsDidChangeNotification
                                                     object:self.document.managedObjectContext];
  
          [[NSNotificationCenter defaultCenter] addObserver:self
                                                   selector:@selector(contextDidSave:)
                                                       name:NSManagedObjectContextDidSaveNotification
                                                     object:self.document.managedObjectContext];
      }
      return self;
  }
  
  
  - (void)performWithDocument:(OnDocumentReady)onDocumentReady {    
      void (^OnDocumentDidLoad)(BOOL) = ^(BOOL success) {
          onDocumentReady(self.document);
      };
  
      if (![[NSFileManager defaultManager] fileExistsAtPath:[self.document.fileURL path]]) {
          [self.document saveToURL:self.document.fileURL
                  forSaveOperation:UIDocumentSaveForCreating
                 completionHandler:OnDocumentDidLoad];
      } else if (self.document.documentState == UIDocumentStateClosed) {
          [self.document openWithCompletionHandler:OnDocumentDidLoad];
      } else if (self.document.documentState == UIDocumentStateNormal) {
          OnDocumentDidLoad(YES);
      }
  }
  </code></pre>
  
  <p>'</p>
  
  <p>Using the context from the document I create NSManagedObjects (standard Core Data stuff, right?). The problem is that I get this error when I run the app:</p>
  
  <p>"Can't merge models with two different entities named"</p>
  
  <p>I'm in over my head with this DocumentHandler, and I hope this is an easy fix I'm too stupid/inexperienced to see.</p>
  
  <p>I havent' made separate versions of the data model or anything and I'm not trying to migrate anything. I just want to run this app for the first time!</p>
  
  <p>Thanks for reading.</p>