Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3356562
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T02:31:40+00:00 2026-05-18T02:31:40+00:00

Everytime I add a new Attribute to my CodeData object model I have to

  • 0

Everytime I add a new Attribute to my CodeData object model I have to clear my database file out otherwise I get the following error:

2010-11-13 15:26:44.580 MyApp[67066:207] * Terminating app due to uncaught exception ‘NSInternalInconsistencyException’, reason: ‘+entityForName: could not locate an NSManagedObjectModel for entity name ‘myApp”

There must be a way of being able to add extra fields without losing the whole database.

What do I need to do to retain my data?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T02:31:41+00:00Added an answer on May 18, 2026 at 2:31 am

    there is a way, and this way is called automatic lightweight migration. It needs a codechange and an extra step when changing your object model.

    For the code you have to add two options to the method where you initialize your persistent store coordinator. something like this:

    - (NSPersistentStoreCoordinator *)persistentStoreCoordinator {
        if (persistentStoreCoordinator_ != nil) {
            return persistentStoreCoordinator_;
        }
        NSString *storePath = [AppDelegate_Shared coredataDatabasePath];
        NSURL *storeURL = [NSURL fileURLWithPath:storePath];
    
    // important part starts here
        NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:
                                 [NSNumber numberWithBool:YES], NSMigratePersistentStoresAutomaticallyOption, 
                                 [NSNumber numberWithBool:YES], NSInferMappingModelAutomaticallyOption, 
                                 nil];
        NSError *error = nil;
        persistentStoreCoordinator_ = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:[self managedObjectModel]];
        if (![persistentStoreCoordinator_ addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeURL options:options error:&error]) {
    // and ends here
    
            LogError(@"Unresolved error %@, %@", error, [error userInfo]);
            // Do something 
        }    
        return persistentStoreCoordinator_;
    }
    

    Now if you want to change your model, you have to create a model version before you do any changes.
    Select your datamodel, and go into the main menu Design -> Data Model -> Add Model Version. Your “old” model will be renamed and you make your changes in the current model, the one with the green mark.
    All the old models are kept and will be put into your application, so your app can perform the ‘automatic lightweight migration’ and upgrade the existing database to your new model.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Everytime I upload a file to my ASP.NET site, all users are logged out
I have a old website that generate its own RSS everytime a new post
I have a medium size Java file. Everytime I make a change to one
Everytime I add a new Form to my WinForms project, the designer generates code
I would like a new log file created everytime the application starts. If a
I am using an ASP.NET MVC project and everytime I add a class to
I get an error everytime I upload my webapp to the provider. Because of
Today, everytime I try to open any .Net application I get: CLR error: 80004005
I'm relatively new to Threading in Java and I've noticed that everytime I use
With JPA I do not need to code the SQL for every new attribute

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.