I have isolated the problem to having a nested editor situation. I have included a sample project. Create a patient, add a note to the patient, and upload a file. Click ok to save/persist the note, then ok to save/persist the patient… You will get a sys_pkey_constraint violation because somewhere the framework is attempting to re-save the already-persisted (in code) file descriptor.
I need this to work because I have onscreen preview of the image/document, as @mario shows in his guide with the pet clinic. dataManager.commit() makes the preview work before full persisting of the entities (ok’ing on both editors). But with that in… you get this pkey constraint error.
It’s because DataManager.commit() returns another object. Previous object was “new” and returned object is the saved object in the “detached” state.
If you add “new” object to the docsDc.mutableItems collection, data context tries to save it again on screen commit.
Interesting! Yes, that makes it all work! Thank you so much @AlexBudarov
I had adapted code from a posted example that did not use the return value of dm.commit() and of course without doing that you get a bunch of problems.