[BUGFIX] Set correct foreign parentkey when writing inline relations