is anyone facing the error, "The current model reference and the next model reference cannot be equal", when using SwiftData with migration and iCloud/CloudKit integration?
The current model reference and the next model reference cannot be equal.
Did you ever figure out the problem? I just ran into it myself and don't see anything obviously wrong. If I figure it out, I'll post again here with my findings.
I just figured it out in my case.
Each of my two 2 VersionedSchemas, V1 and V2, was referring to its static models as [A.self, B.self], which is fine. But I had forgotten that I had also typealiased A and B to the current schema ("typealias A = V1.A"), which was overriding the static references.
I fixed it by referring to the static models within the VersionedSchemas as [Self.A.self, Self.B.self], avoiding confusion with the typealiases.
I came across this while googling and thought I'd also put my solution here for any others it helps:
I was bumping the schema just to use the migrations for ensuring data integrity, and I hadn't actually changed the model. Once I made a change to the model (renamed an attribute I had been meaning to get around to) everything worked fine.