title: Error in iPhone core data
body: <p>My <code>AppDelegate.h</code>:</p>
  
  <pre><code>#import &lt;UIKit/UIKit.h&gt;
  #import "Child.h"
  
  @interface AppDelegate : UIResponder &lt;UIApplicationDelegate&gt; {
      NSManagedObjectModel *managedObjectModel;
      NSManagedObjectContext *managedObjectContext;
      NSPersistentStoreCoordinator *persistentStoreCoordinator;
  }
  @property (readonly, strong, nonatomic) NSManagedObjectContext *managedObjectContext;
  @property (readonly, retain, nonatomic) NSManagedObjectModel *managedObjectModel;
  @property (readonly, strong, nonatomic) NSPersistentStoreCoordinator *persistentStoreCoordinator;
  - (NSString *)applicationDocumentsDirectory;
  @property (strong, nonatomic) UIWindow *window;
  @end
  </code></pre>
  
  <p><code>AppDelegate.m</code>:</p>
  
  <pre><code>#import "AppDelegate.h"
  @implementation AppDelegate
  
  @synthesize managedObjectContext = __managedObjectContext;
  @synthesize managedObjectModel = __managedObjectModel;
  @synthesize persistentStoreCoordinator = __persistentStoreCoordinator;
  @synthesize window = _window;
  
  - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
      // Override point for customization after application launch.
      NSManagedObjectContext *context = [self managedObjectContext];
      if (!context) {
          NSLog(@"Error");
      }
      return YES;
  }
  - (void)applicationWillTerminate:(UIApplication *)application { /* Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. */
      NSError *error;
      if (managedObjectContext != nil) {
          if ([managedObjectContext hasChanges] &amp;&amp; ![managedObjectContext save:&amp;error]) {
          // Handle the error.
          } 
      }
  }
  // Explicitly write Core Data accessors
  - (NSManagedObjectContext *) managedObjectContext {
      if (managedObjectContext != nil) {
          return managedObjectContext;
      }
      NSPersistentStoreCoordinator *coordinator = [self persistentStoreCoordinator];
      if (coordinator != nil) {
          managedObjectContext = [[NSManagedObjectContext alloc] init];
          [managedObjectContext setPersistentStoreCoordinator: coordinator];
      }
      return managedObjectContext;
  }
  - (NSManagedObjectModel *)managedObjectModel {
      if (managedObjectModel != nil) {
          return managedObjectModel;
      }
      managedObjectModel = [NSManagedObjectModel mergedModelFromBundles:nil];
      return managedObjectModel;
  }
  - (NSPersistentStoreCoordinator *)persistentStoreCoordinator {
      if (persistentStoreCoordinator != nil) {
          return persistentStoreCoordinator;
      }
      NSURL *storeUrl = [NSURL fileURLWithPath: [[self applicationDocumentsDirectory] stringByAppendingPathComponent: @"iSalahProject.sqlite"]];
      NSError *error = nil;
      persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:[self managedObjectModel]];
      if(![persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeUrl options:nil error:&amp;error]) {
          /*Error for store creation should be handled in here*/
      }
      return persistentStoreCoordinator;
  }
  - (NSString *)applicationDocumentsDirectory {
      NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
      NSString *basePath = ([paths count] &gt; 0) ? [paths objectAtIndex:0] : nil;
      return basePath;
  }
  @end
  </code></pre>
  
  <p>My controller implementation class where entity is being created and I am getting the error:</p>
  
  <pre><code>-(IBAction)addChildren:(id)sender{
      inputChildName = nameOfChild.text;
      NSManagedObjectContext *context = [app managedObjectContext];
      Child * childrenName = [NSEntityDescription insertNewObjectForEntityForName:@"Child" inManagedObjectContext:context];
      childrenName.name = inputChildName;
  }
  </code></pre>
  
  <p>The error I am getting is:</p>
  
  <pre><code>*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '+entityForName: could not locate an NSManagedObjectModel for entity name 'Child''
  </code></pre>
  
  <p>I am using iOS-5 XCode 4.2 ARC. Please help me resolving this issue, I already have spent hours resolving it, but I couldn't find any solutions.</p>