String uri = link.getHref();
String entitySetName = e.getKind();
String key = uri.substring(uri.lastIndexOf('('));
EdmEntitySet ees = metadata.getEdmEntitySet(entitySetName);
EdmEntityType eet = ees.getType();
EdmNavigationProperty enp = eet.findNavigationProperty(link.getRelation());
EdmMultiplicity em = enp.getRelationship().getEnd2().getMultiplicity();
Entity entity = findEntity(enp.getToRole().getType().getName(), OEntityKey.parse(key));
if (em == EdmMultiplicity.ZERO_TO_ONE) {
e.setProperty(link.getRelation(), entity.getKey());
} else {