Failed to find entity of type in route in Drupal\Core\Entity\Enhancer\EntityRouteEnhancer->enhanceEntityView()

You can get this error when trying to show a custom entity in a controller. Problem is probably your route. Make sure it has a "parameters" section pointing to the right entity type like:

contest.winner_detail:
  path: '/contest/wall-of-fame/{id}'
  defaults:
    _entity_view: contest.winner
  requirements:
    _access: 'TRUE'
  options:
    no_cache: 'TRUE'
    parameters:
      id:
        type: 'entity:contest'

 

 

Saved you some valuable time?

Buy me a drink 🍺 to keep me motivated to create free content like this!