Re: Core Data Migration Exception

  • Hello,

    Can anyone spot any obvious errors I'm making in the following
    experiment? I'm not interested in versioning at this point, I just want
    to actually see the migration happen successfully.

    I created a new Leopard Xcode 3 project to test the default automatic
    migration -- just to be sure I had my head around it.  It didn't go well.

    Here's what I did:

    1.  created a new Core Data Application Project, MigrationTest

    2.  added an entity, TestEntity, with one attribute to the MigrationTest
        model

    3.  built and ran MigrationTest

    4.  confirmed (using SQL Browser Lite) that the database had been created
        as expected.  Noted that the Z_METADATA table had no records.

    5.  using the Design menu, added a duplicate model, called
        MigrationTest-2 to the MigrationTest project (I get the same
        results if I use a versioned model: a .xcdatamodeld packagte
        containing two .xcdatamodel models)

    6.  added an new attribute to TestEntity (to have a change to migrate)

    The next two steps, 7 and 8, are related to step 9

    7.  changed the original model's name to MigrationTest-orig

    8.  renamed the new model, MigrationTest-2, to, simply, MigrationTest

    9.  modified the -managedObjectModel method to avoid the error

            'Can't merge models with two different entities named ...'

        by calling NSManagedModel's -initWithContentsOfUrl to specifically
        load the 'MigrationTest' Model rather than calling one of its more
        convenient sisters: the four model-merging class methods.

    10. used the Design menu to create a Mapping Model.

    11. cleaned, built and ran MigrationTest

    Result:

    rather than migrating the model, it displayed five cascading alerts all
    saying:

            The file “MigrationTest.sqlâ€? could not be opened
            because it is not in the right format.

            The file might be corrupted, truncated, or in a
            different format than you expect.

    Is it bug report time or am I missing a point somewhere?

    Thanks,

    Steve
  • On Jan 10, 2008, at 12:23 AM, Steve Steinitz wrote:

    > I created a new Leopard Xcode 3 project to test the default automatic
    > migration -- just to be sure I had my head around it.  It didn't go
    > well.
    >
    Sorry, I don't have time to look at this more closely at the moment,
    but it's still not clear why you're creating two models rather than a
    single versioned model.

    If you want to look at a working example, see <http://homepage.mac.com/mmalc/CocoaExamples/MigratingDepartmentAndEmployees
    .zip
    >.

    mmalc
  • Hi mmalc,

    On 10/1/08, mmalc crawford wrote:

    > If you want to look at a working example, see < http://homepage.mac.com/mmalc/CocoaExamples/MigratingDepartmentAndEmployee
    s.zip
    > .

    Thank you for that characteristically excellent, spot-on reference.
    Its exactly what I needed.

    All the best,

    Steve
previous month january 2008 next month
MTWTFSS
  1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31      
Go to today