elementsense
elementsense

Reputation: 1540

How to migrate new data model in a CoreData project?

I have a simple problem, I have an app based on CoreData and I need to change the structure a little. How can I migrate the old structure into the new one. Just adding one attribute will chrash the whole app.

Thanks

Upvotes: 1

Views: 223

Answers (3)

Ben Mosher
Ben Mosher

Reputation: 13381

When you finally do get to the point where you want to version, you add a new one by clicking on your core data model file (YourApp.xcdatamodel). Then pull down the 'Design' menu, hover on 'Data Model', and click 'Add Model Version'.

Don't forget to change your model extension from 'mom' to 'momd' (wherever you're loading it, probably in your app delegate), and when you have your new version in hand, go back to that menu and click 'Set Current Version'.

Design menu image

Upvotes: 0

Alex Reynolds
Alex Reynolds

Reputation: 96927

Once you have the basics of Core Data down, you can implement versioning. Until then, if you're just testing things out, you can always delete the app from the Simulator or device. Reinstalling the app will create a fresh data store (usually).

Upvotes: 0

Related Questions