Post

Replies

Boosts

Views

Activity

Reply to SwiftData: "Illegal attempt to establish a relationship 'item' between objects in different contexts
Forgot to mention, I made sure to add the new MyItem type to the schema as well: struct SwiftDataBugTestApp: App { var sharedModelContainer: ModelContainer = { let schema = Schema([ Item.self, MyItem.self ]) let modelConfiguration = ModelConfiguration(schema: schema, isStoredInMemoryOnly: false) do { return try ModelContainer(for: schema, configurations: [modelConfiguration]) } catch { fatalError("Could not create ModelContainer: \(error)") } }() var body: some Scene { WindowGroup { ContentView() } .modelContainer(sharedModelContainer) } }
Oct ’23