What do I have to do to get Core Data to automatically migrate models?

前端 未结 10 1906
感情败类
感情败类 2020-11-27 09:14

I have read the documentation about automatic /lightweight migration for Core Data models - but I am having problems implementing it.

As I understand it the applicat

10条回答
  •  天涯浪人
    2020-11-27 09:16

    I've had this issue for years, and I tried all of these answers to no avail. Today I finally figured out what I was doing wrong. Very simple problem, but I overlooked it. When creating a newer version of the data model, if you are ADDING columns make sure to mark them as OPTIONAL. If you do not the simple migration will not work because the new column values will not be filled in.

    As soon as I made sure my new columns has "optional" checked, I tried the migration again and it worked.

提交回复
热议问题