Added function for ensuring Ids in embedded models