Getting Fatal Error using SwiftData for previews after switching to Xcode 16

I was creating a sample SwiftData project using two models and a one to one relationship. Before upgrading to xcode 16, everything was fine and compiled correctly. After upgrading to xcode 16, I get fatal errors: "This model instance was destroyed by calling ModelContext.reset and is no longer usable" or

The error you described seems to be the same as the one described in the iOS 18 strange SwiftData fatal error post, and so let's follow up from there.

Best,
——
Ziqiao Chen
 Worldwide Developer Relations.

Getting Fatal Error using SwiftData for previews after switching to Xcode 16
 
 
Q