title: Implementation of "Automatic Lightweight Migration" for Core Data (iPhone)
body: <p>I would like to make my app able to do an automatic lightweight migration when I add
  new attributes to my core data model.</p>
  <p>In the guide from Apple this is the only info on the subject I could find:</p>
  <blockquote>
  <p><strong>Automatic Lightweight Migration</strong></p>
  <p>To request automatic lightweight
  migration, you set appropriate flags
  in the options dictionary you pass in
  addPersistentStoreWithType:configuration:URL:options:error:.
  You need to set values corresponding
  to both the
  NSMigratePersistentStoresAutomaticallyOption
  and the
  NSInferMappingModelAutomaticallyOption
  keys to YES:</p>
  </blockquote>
  <pre><code>NSError *error;
  NSURL *storeURL = &lt;#The URL of a persistent store#&gt;;
  NSPersistentStoreCoordinator *psc = &lt;#The coordinator#&gt;;
  NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:
      [NSNumber numberWithBool:YES], NSMigratePersistentStoresAutomaticallyOption,
      [NSNumber numberWithBool:YES], NSInferMappingModelAutomaticallyOption, nil];
   
  if (![psc addPersistentStoreWithType:&lt;#Store type#&gt;
      configuration:&lt;#Configuration or nil#&gt; URL:storeURL
      options:options error:&amp;error]) {
      // Handle the error.
  }
  </code></pre>
  <p>My <code>NSPersistentStoreCoordinator</code> is initialized in this way:</p>
  <pre><code>- (NSPersistentStoreCoordinator *)persistentStoreCoordinator {
      
      if (persistentStoreCoordinator != nil) {
          return persistentStoreCoordinator;
      }
      
      NSURL *storeUrl = [NSURL fileURLWithPath: [[self applicationDocumentsDirectory] stringByAppendingPathComponent: @&quot;FC.sqlite&quot;]];
      
      NSError *error = nil;
      persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:[self managedObjectModel]];
      if (![persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeUrl options:nil error:&amp;error]) {
  
          NSLog(@&quot;Unresolved error %@, %@&quot;, error, [error userInfo]);
          abort();
      }    
      
      return persistentStoreCoordinator;
  }
  </code></pre>
  <p><strong>I am having trouble seeing where and how I should add the Apple code to get the Automatic Lightweight Migration working?</strong></p>