title: Symfony Media bundle - "Impossible to invoke a method ("id") on a null variable."
body: <p><strong>Environment</strong></p>
  
  <p>Symfony 3.4.4 + FOSBundleUser + Sonata Admin + Media Bundle</p>
  
  <p><strong>Subject</strong></p>
  
  <p>I have installed Media Bundle.
  I have configured it following the steps indicated in the Official documentation.</p>
  
  <p>I have created a field in my entity Products to attach a catalog in PDF format.</p>
  
  <p>I have added in Sonata Adminel field mapping.</p>
  
  <p>When viewing the list of products in Sonata Admin, there is no problem, but when enter to edit or create a new product, give this error:</p>
  
  <blockquote>
    <p>Impossible to invoke a method ("id") on a null variable.</p>
  </blockquote>
  
  <p>This is the definition of my field to attach a PDF in my entity</p>
  
  <pre><code>/**
   * @var Media
   *
   * @ORM\ManyToOne(targetEntity="Application\Sonata\MediaBundle\Entity\Media")
   * @ORM\JoinColumns({
   *     @ORM\JoinColumn(name="fileCatalog_id", referencedColumnName="id")
   * })
   */
  private $fileCatalog;
  </code></pre>
  
  <p>This is the mapping of the field in the Sonata Admin form</p>
  
  <pre><code>-&gt;add('fileCatalog', 'sonata_type_model_list', array(
                      'required' =&gt; false,
                      'label'=&gt;'Imagen Español'
                  ), array(
                          'link_parameters' =&gt; array(
                              'context' =&gt; 'default',
                              'provider' =&gt; 'sonata.media.provider.file',
                              'empty_on_new' =&gt; true,
                          )
                      )
                  )
  </code></pre>