title: could not locate an NSManagedObjectModel for entity name
body: <p>This is the code for toggleAddProject method, the Core Data code is almost the same as found in Apple's CoreDataBooks sample, however when I click the add button the app crashes with <code>entityForName: could not locate an NSManagedObjectModel for entity name 'Project'</code> on the line starting with <code>newProjectController.project</code></p>
  
  <pre><code>-(IBAction)toggleAddProject 
  {
      NewProjectViewController *newProjectController = [[[NewProjectViewController alloc] initWithStyle:UITableViewStyleGrouped] autorelease];
  
      // Create a new managed object context for the new project -- set its persistent store coordinator to the same as that from the fetched results controller's context.
      NSManagedObjectContext *addingContext = [[NSManagedObjectContext alloc] init];
      self.addingManagedObjectContext = addingContext;
      [addingManagedObjectContext setPersistentStoreCoordinator:[[fetchedResultsController managedObjectContext] persistentStoreCoordinator]];
      newProjectController.project = (Project *)[NSEntityDescription insertNewObjectForEntityForName:@"Project" inManagedObjectContext:addingContext];
      [addingContext release];
  
  
      UINavigationController *addNewNavigationController = [[UINavigationController alloc] initWithRootViewController:newProjectController];
      [self.navigationController presentModalViewController:addNewNavigationController animated:YES];  
      [addNewNavigationController release];
  }
  </code></pre>
  
  <p>Everything has been synthesized, the Project entity exists. I can't figure out why it crashes. Most people seem to be able to fix this error by inserting the following code either in the method itself, or in viewDidLoad:</p>
  
  <pre><code>if (managedObjectContext == nil) 
  { 
      managedObjectContext = [(CoreDataBooksAppDelegate *)[[UIApplication sharedApplication] delegate] managedObjectContext]; 
  }
  </code></pre>
  
  <p>When modified for my app delegate it makes no difference. Thanks for any help.</p>