Add safeguard to prevent entity duplication.