SwiftData Relations

Saving a single relation is not an issue but a one to many is building but giving an error on runtime. This occurs on a new record.
The save :
Button(“Save”) {
//save record, then dismiss
subcatagory.name = name
subcatagory.catagory = Catagory(id: “”, name: “”, instrument: )
subcatagory.catagory?.name = selectedCatagory
if !editMode {
//new record - editMode = false
context.insert(subcatagory)
} else {
//update record - editMode = true
try? context.save()
}
dismiss()
All the var for input have been confirmed prior to the save.
The models and error ;


Not sure on how to interpret the error code which occurs on Save() Likely the relationship setup is the issue but cannot see it .
Any comments are appreciated . TIA