Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NSManagedObjectModel error #96

Open
eugeniobaglieri opened this issue Nov 11, 2018 · 10 comments
Open

NSManagedObjectModel error #96

eugeniobaglieri opened this issue Nov 11, 2018 · 10 comments

Comments

@eugeniobaglieri
Copy link

eugeniobaglieri commented Nov 11, 2018

while running the example project, I get an infinite list of these errors in console log:

[error] error: The fetch request's entity 0x2819d0a50 'Device' appears to be from a different NSManagedObjectModel than this context's
CoreData: error: The fetch request's entity 0x2819d0a50 'Device' appears to be from a different NSManagedObjectModel than this context's
[error] error: The fetch request's entity 0x2819d09a0 'Event' appears to be from a different NSManagedObjectModel than this context's
CoreData: error: The fetch request's entity 0x2819d09a0 'Event' appears to be from a different NSManagedObjectModel than this context's

How can I resolve?

@eugeniobaglieri
Copy link
Author

eugeniobaglieri commented Nov 11, 2018 via email

@lvandal
Copy link

lvandal commented Dec 4, 2018

I get the same error as well.

@lvandal
Copy link

lvandal commented Dec 5, 2018

Perhaps this fix could be applied here? superk589/DereGuide#24

@DJ-Glock
Copy link

DJ-Glock commented Jan 8, 2019

I believe this issue happens with all projects that use Seam3. It looks like it happens because Seam3 does some work in a background thread. Not sure if it can be solved. In my project these warnings did not cause any issues so far.

@hyerra
Copy link
Collaborator

hyerra commented Jan 17, 2019

I wonder if this is due to the fact that we are adding some extra backing store attributes that might cause the model to change. Maybe if we had the user manually add this into the model, this message wouldn't show.

@mklybor
Copy link

mklybor commented Apr 23, 2019

Wondering if this issue has been addressed in the two updates that were merged recently. I just cloned seam3, added it to my app, and got the same nsmanagedobjectmodel error.

@mklybor
Copy link

mklybor commented Apr 24, 2019

got a fix. @hyerra had diagnosed right. it was fetching into the backing context using a fetch request that contained an entity description from (I guess) the view context.

my fix is to create a copy of the fetch request using the entity from the backing context with the same entity name as in the original fetch request:

func executeInResponseToFetchRequest(_ fetchRequest:NSFetchRequest,context:NSManagedObjectContext) throws ->[Any] {

    let newFetchRequest = fetchRequest.copy(with: nil) as! NSFetchRequest<NSFetchRequestResult>
    let entityName = newFetchRequest.entityName
    let entities = backingMOC.persistentStoreCoordinator?.managedObjectModel.entitiesByName
    let entity = entities![entityName!]
    newFetchRequest.entity = entity
    
    let resultsFromLocalStore = try self.backingMOC.fetch(newFetchRequest)

@brianminor
Copy link

brianminor commented Jul 9, 2019

@mklybor any chance you can share a little more on how you're doing it? I'm newer to CoreData and having the same issue.

@mklybor
Copy link

mklybor commented Jul 9, 2019

Look at my branch for the fix:

https://github.com/mklybor/Seam3/tree/fix_model_error

there was a fetch request that had an issue that was causing the warning msg.

this should get rolled into the master.

@daviddelmonte
Copy link

Has this been rolled into the master? Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants