title: Unable to guess how to get a Doctrine instance
body: <p>I have been through the process of updating my project from Symfony 2.8 to Symfony 3 and am now reworking one of my controllers but am having some trouble.</p>
  
  <p>I have a Child entity and controller.  The controller has a base route</p>
  
  <pre><code>/**
  * Child controller.
  *
  * @Route("/profile/{parentName}/{childName}")
  */
  </code></pre>
  
  <p>with an action</p>
  
  <pre><code>/**
   * Finds and displays a Child entity.
   *
   * @Route("/{id}", name="child_show")
   * @Method("GET")
   * @Template()
   */
  public function showAction(Child $child)
  {
      $deleteForm = $this-&gt;createDeleteForm($child);
  
      return array(
          'child' =&gt; $child,
          'delete_form' =&gt; $deleteForm-&gt;createView(),
      );
  }
  </code></pre>
  
  <p>However I don't want the page URL to be domain.com/parentname/childname/id I want it to be domain.com/parentname/childname</p>
  
  <p>In 2.8 my controller was</p>
  
  <pre><code>/**
  * Child controller.
  *
  * @Route("/profile/{parentName}/{childName}")
  */
  
  
  /**
   * Finds and displays a Child entity.
   *
   * @Route("/", name="child_show")
   * @Method("GET")
   * @Template()
   */
  public function showAction($childName)
  {
  
      $em = $this-&gt;getDoctrine()-&gt;getManager();
      $entity = $em-&gt;getRepository('AppBundle:Child')-&gt;findOneByName($childName);
      if (!$entity) {
          throw $this-&gt;createNotFoundException('Unable to find Child entity.');
      }
  
      $deleteForm = $this-&gt;createDeleteForm($childName);
  
      return array(
          'entity'      =&gt; $entity,
          'delete_form' =&gt; $deleteForm-&gt;createView(),
      );
  }
  </code></pre>
  
  <p>and it worked as I wanted.</p>
  
  <p>However if in my updated controller I modify the route annotation on showAction to </p>
  
  <pre><code>/**
  * @Route("/", name="child_show")
  * @Method("GET")
  * @Template()
  */
  </code></pre>
  
  <p>I get an error <em>Unable to guess how to get a Doctrine instance from the request information.</em> I guess because the Id is needed to get the correct instance of Child?  However childName ($name) in the Child entity is also unique.</p>
  
  <p>I'm a bit stuck with this.  Can anyone advise what I am doing wrong?  I want to be able to have a route for the child profile page that doesn't contain the ID but uses the child's name to return the info required.</p>
  
  <p>Update in response to some comments / questions - below is my Child entity</p>
  
  <pre><code>namespace AppBundle\Entity;
  
  use Doctrine\ORM\Mapping as ORM;
  use AppBundle\Entity\User;
  use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  
  /**
  * Child
  *
  * @ORM\Table()
  * @ORM\Entity(repositoryClass="AppBundle\Entity\ChildRepository")
  * @UniqueEntity("name")
  */
  
  class Child
  {
  
  /**
   * @var integer
   * @ORM\Column(name="id", type="integer")
   * @ORM\Id
   * @ORM\GeneratedValue(strategy="AUTO")
   */
  private $id;
  
  /**
   * @var string
   *
   * @ORM\Column(name="name", type="string", length=255, unique=true)
   */
  private $name;
  
  /*
  * Todo - figure out how to use a date type for dateofbirth below and as well in users.yml fixtures file
  */
  
  /**
   * @var \DateTime
   *
   * @ORM\Column(name="date_of_birth", type="datetime")
   */
  private $dateOfBirth;
  
  //todo find ot why the parent variable here and Id variable in AppBundle:User are not mapped correctly
  /**
   * @ORM\ManyToOne(targetEntity="AppBundle\Entity\User", inversedBy="id")
   * @ORM\JoinColumn(onDelete="CASCADE")
   */
  
  private $parent;
  
  /**
   * @return User
   */
  public function getParent()
  {
      return $this-&gt;parent;
  }
  
  /**
   * @param User $parent
   */
  public function setParent(User $parent)
  {
      $this-&gt;parent = $parent;
  }
  
  
  /**
   * Get id
   *
   * @return integer
   */
  public function getId()
  {
      return $this-&gt;id;
  }
  
  /**
   * Set name
   *
   * @param string $name
   *
   * @return Child
   */
  public function setName($name)
  {
      $this-&gt;name = $name;
  
      return $this;
  }
  
  /**
   * Get name
   *
   * @return string
   */
  public function getName()
  {
      return $this-&gt;name;
  }
  
  
  /**
   * Set dateOfBirth
   *
   * @param \DateTime $dateOfBirth
   *
   * @return Child
   */
  public function setDateOfBirth($dateOfBirth)
  {
      $this-&gt;dateOfBirth = $dateOfBirth;
  
      return $this;
  }
  
  /**
   * Get dateOfBirth
   *
   * @return \DateTime
   */
  public function getDateOfBirth()
  {
      return $this-&gt;dateOfBirth;
  }
  }
  </code></pre>
  
  <p>and modified the showAction to </p>
  
  <pre><code>/**
  * Child controller.
  *
  * @Route("/profile/{parentName}/{name}")
  */
  
  /**
   * Finds and displays a Child entity.
   *
   * @Route("/", name="child_show")
   * @Method("GET")
   * @Template()
   */
  public function showAction(Child $name)
  {
      $deleteForm = $this-&gt;createDeleteForm($name);
  
      return array(
          'child' =&gt; $name,
          'delete_form' =&gt; $deleteForm-&gt;createView(),
      );
  }
  </code></pre>
  
  <p>but I now get an error <em>AppBundle\Entity\Child object not found.</em></p>
  
  <pre><code>ERROR - Uncaught PHP Exception  
  
  Symfony\Component\HttpKernel\Exception\NotFoundHttpException:     "AppBundle\Entity\Child object not found." at /Library/WebServer/Documents/story-project/app/cache/dev/classes.php line 7183 
  </code></pre>