You cannot set item directly in the init(name:item:) for MyItem class.
This should work
private func addItem() {
withAnimation {
let newItem = Item(timestamp: Date())
modelContext.insert(newItem)
let newMyItem = MyItem(name: "Test")
modelContext.insert(newMyItem)
newMyItem.item = newItem
}
}