Checking entity by model name

This patch fixes an error when no entity found.