3

I'm currently working on an app which, will hopefully, use Core Data to store/retrieve data from 2 sqlite files (At the moment it just uses 1). I realise to do this I have to create another configuration in the Core Data Model Editor of Xcode which I have done. Now, I am trying to move entities from my current configuration into the new one but I cant find a way of doing it. I'm using Xcode version 4.5.1.

Am i doing this right? How do you move move entities between configurations?

Any help is much appreciated :)

JDx
  • 2,615
  • 3
  • 22
  • 33

3 Answers3

6

Select one configuration in the left pane of the model editor and then drag'n'drop one or more of its entities from the right pane to another configuration in the left pane. This will copy the entity, so you still need to delete it from the original configuration.

Dorian Roy
  • 3,094
  • 2
  • 31
  • 51
2

This worked for me in Xcode 7.2.1:

  1. Display the source model, select the source entity, select Edit menu/copy.
  2. Display the target model. In the Entities pane Add Entity (+) for new entity.
  3. Select the new entity and click Edit menu/paste.
mark
  • 181
  • 6
1

I know of two approaches depending on how many entities you need to transfer.

If you want most or all of the entities to be copied, you can copy and rename your existing xcdatamodel in the Finder, then add the new file to the project. I've done this as a test, but since I'm only working with a single versioned model, I haven't gone through to production with a model entered this way, so I don't know if there are any downsides.

If you only have a few entities to transfer, simply select the entity in one model, copy it (command-c), then select the other model and paste it (command-v). This only works for one entity at a time and you need to do some clean-up afterwards, but it's still better than manually re-entering all of the properties. After copying, update the following in the new model, which don't transfer over cleanly:

  1. Relationship targets and inverses.
  2. Relationship delete rules.
  3. Parent entities.
David Ravetti
  • 2,030
  • 1
  • 17
  • 22