Fix for issue with using relationships as primary keys