ensure id set if not set after save
(cherry picked from commit 791880d)