Is there a safe way to remove the persistent store (and create a new one) in an application, where other threads are using NSManagedObjectContext's associated with the store being removed?
It should be safe if you can guarantee that no live managed objects will attempt to access the persistent store. This part is crucial: you must ensure that there are no live objects of any kind that have been loaded from or otherwise associated with the old persistent store.
You can do this by resetting each managed object context:
[managedObjectContext performBlockAndWait:^{
[managedObjectContext reset];
}];
Once you have done this for every managed object context, you can remove the persistent store.
Note that if you have any managed objects that were fetched from those contexts, you must dispose of them immediately without reading or writing attribute values or using them in any way. These objects might need to use the context for a variety of reasons, but after calling reset the context doesn't know anything about them anymore. Get rid of them immediately (ideally even before calling reset), because they're time bombs waiting to blow up your app the moment you touch them.