Adding new CoreStoreObject to schema gives "The model used to open the store is incompatible with the one used to create the store" error #350

Closed
opened 2025-12-29 15:29:46 +01:00 by adam · 2 comments
Owner

Originally created by @mariusgab on GitHub (Nov 19, 2020).

I want to add a new CoreStoreObject class to my current schema

var entitiesV1 = [
Entity< Entity1>.init("Entity1")
]

var entitiesV2 = [
Entity< Entity1>.init("Entity1"),
Entity< Entity2>.init("Entity2")
]

let schemaV1 = CoreStoreSchema.init(modelVersion: "1", entities: entitiesV1)
let schemaV2 = CoreStoreSchema.init(modelVersion: "2", entities: entitiesV2)
        
let dataStack = DataStack.init(
 schemaHistory: SchemaHistory.init(allSchema: [schemaV1,schemaV2],migrationChain: ["1","2"])
 )
CoreStoreDefaults.dataStack  = dataStack
try CoreStoreDefaults.dataStack.addStorageAndWait()

This returns error "The model used to open the store is incompatible with the one used to create the store".
What exactly is wrong here if anyone can help me?

Originally created by @mariusgab on GitHub (Nov 19, 2020). I want to add a new CoreStoreObject class to my current schema ``` var entitiesV1 = [ Entity< Entity1>.init("Entity1") ] var entitiesV2 = [ Entity< Entity1>.init("Entity1"), Entity< Entity2>.init("Entity2") ] let schemaV1 = CoreStoreSchema.init(modelVersion: "1", entities: entitiesV1) let schemaV2 = CoreStoreSchema.init(modelVersion: "2", entities: entitiesV2) let dataStack = DataStack.init( schemaHistory: SchemaHistory.init(allSchema: [schemaV1,schemaV2],migrationChain: ["1","2"]) ) CoreStoreDefaults.dataStack = dataStack try CoreStoreDefaults.dataStack.addStorageAndWait() ``` This returns error "The model used to open the store is incompatible with the one used to create the store". What exactly is wrong here if anyone can help me?
adam closed this issue 2025-12-29 15:29:47 +01:00
Author
Owner

@JohnEstropia commented on GitHub (Nov 20, 2020):

@VMariusGabriel You can't use migrations with the synchronous addStorageAndWait() method. Use the asynchronous addStorage(...completion:). See https://github.com/JohnEstropia/CoreStore#starting-migrations

@JohnEstropia commented on GitHub (Nov 20, 2020): @VMariusGabriel You can't use migrations with the synchronous `addStorageAndWait()` method. Use the asynchronous `addStorage(...completion:)`. See https://github.com/JohnEstropia/CoreStore#starting-migrations
Author
Owner

@mariusgab commented on GitHub (Nov 20, 2020):

Thank you!

@mariusgab commented on GitHub (Nov 20, 2020): Thank you!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/CoreStore#350