title: Core Data Crash - The NSPersistentStoreCoordinator has no persistent stores (corrupt file)
body: <p>I am seeing a few crash reports with this title:</p>
  
  <p>The NSPersistentStoreCoordinator has no persistent stores (corrupt file). It cannot perform a save operation.  My code for adding the persistent store to the coordinator is here:</p>
  
  <pre><code>    NSURL *applicationDocumentsDirectory = [[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask].lastObject;
  
      NSURL *storeURL = [applicationDocumentsDirectory URLByAppendingPathComponent:@"myDatabase.sqlite"];
  
      NSURL *modelURL = [[NSBundle mainBundle] URLForResource:@"myDataModel" withExtension:@"momd"];
  
      NSManagedObjectModel *managedObjectModel = [[NSManagedObjectModel alloc] initWithContentsOfURL:modelURL];
  
      NSDictionary *storeOptions = @{NSInferMappingModelAutomaticallyOption:@YES,
                                     NSMigratePersistentStoresAutomaticallyOption:@YES,
                                     NSSQLitePragmasOption:@{@"synchronous": @"OFF"}};
  
      // Create the persistent store.
      self.persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:managedObjectModel];
      NSError *error = nil;
      if (![self.persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType
                                                         configuration:nil
                                                                   URL:storeURL
                                                               options:storeOptions
                                                                 error:&amp;error])
     {
  
      }
  </code></pre>
  
  <p>I have logged the error that comes out of the 'addPersistentStoreWithType' call, and it is the following:</p>
  
  <pre><code>NSCocoaErrorDomain 259
  NSSQLiteErrorDomain = 11;
  NSUnderlyingException = "Fatal error. The database at &lt;path&gt; is corrupted. SQLite Error code:11, 'database disk image is malformed'
  </code></pre>
  
  <p>I assume this means the core data base is damanged on unrecoverable.  Is that the case?  I have a backup plan of destorying the core database and repopulating from my server, but I would like to know if its definitely unrecoverable, and if there is anyting I can do to figure out why it may have happened in the first place.</p>
  
  <p>Some additional information:</p>
  
  <p>The crash reports note RAM Free 3-6%, Disk Free 57%, newer model phones running iOS 10.  The version of the app that started seeing these reports also was the first version that had a lightweight core data migration as part of it, I'm not sure if that makes a difference.  I do know that 98% of users successfully upgraded to that version and did the migration with no problem.  Here is the stack trace from the report.  Despite what it says about "device_locked", I know this crash happens anytime I try to save to the persistent store, even when the user is in the app.</p>
  
  <p><a href="https://i.stack.imgur.com/7To4D.png" rel="noreferrer"><img src="https://i.stack.imgur.com/7To4D.png" alt="enter image description here"></a></p>