Improve linkToEntity throwing error