1

I have what I believe to be the simplest possible start to using Magical Record. I simply set up the stack and do a findAll call -- which I expect to return an empty array since this is a first run of the application. My code is below. For some reason, what I actually get is

executeFetchRequest:error: A fetch request must have an entity.

I can't for the life of me figure out why. I don't have versions of my data model, or anything really special. Just an entity and a generated NSMangedObject.. Has anyone seen this before?

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
    [MagicalRecord setupAutoMigratingCoreDataStack];

//    Task *task = [Task MR_createEntity];
//    task.title = @"Title";

    NSArray *contexts = [Task MR_findAll];
    NSLog(@"Initial load found %lu contexts", contexts.count);
}
1

2 Answers 2

2

Did you create and populate an NSManagedObjectModel using Xcode and the Core Data Entity Modeler? The error you're seeing happens when the entity isn't found in the model, or you don't have a model in the first place. Double check your entity name and class names as well. If you aren't using mogenerator, the you will need to make sure they match, or map them yourself using MR_entityName in your own entity's code.

0

Turns out the latest code in the main branch must have a bug.. I pulled the 2.2 branch instead, and it all started working.. Really odd, but there it is for anyone that stumbles on it.. Make sure you pull the latest stable!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.