String targetName = targetEntity.name().toLowerCase();
String selectedName = selectedEntity.name().toLowerCase();
EOAttribute selectedPK = (EOAttribute)targetEntity.primaryKeyAttributes().objectAtIndex(0);
if(foreignAttribute == null) {
foreignAttribute = addAttributeNamed(selectedEntity, targetName+"id", selectedPK.prototype());
}
relationship.setName(targetName+(isToMany ? "s" : ""));
selectedEntity.addRelationship(relationship);
EOJoin join = new EOJoin(foreignAttribute,selectedPK);