Migration with mapping model

The book said, “By setting shouldInferMappingModelAutomatically to false, you’ve ensured that the persistent store coordinator will now use the new mapping model to migrate the store.”

So, Do we have to create a mapping model for v1 to v2? or other mappings that we use the infer mapping before setting shouldInferMappingModelAutomatically to false.

Hiya @skyfoxs - I apologize for the delay in replying!

If you were following along in the chapter, then the app on your simulator or device will have data in the store using model v2. The mapping model you are creating (and now have shoudInferMappingModelAutomatically turned to false) is mapping from v2 to v3. If you would delete the app and skipped the first migration from v1 to v2 (leaving the store at v1), then there would be a crash/error on startup because there is no v1 to v3 mapping model.

Later in the chapter you will read about sequential migrations - so you could use that with the addition of a mapping model of v1 to v2 along with this v2 to v3 model. That would let you upgrade from v1 to v3 incrementally.

Hope that helps!

Oh! I see. Thank you for your answer.

This topic was automatically closed after 166 days. New replies are no longer allowed.