title: Explicitly set Id with Doctrine when using "AUTO" strategy
body: <p>My entity uses this annotation for it's ID:</p>
  
  <pre class="lang-php prettyprint-override"><code>/**
   * @orm:Id
   * @orm:Column(type="integer")
   * @orm:GeneratedValue(strategy="AUTO")
   */
  protected $id;
  </code></pre>
  
  <p>From a clean database, I'm importing in existing records from an older database and trying to keep the same IDs.  Then, when adding new records, I want MySQL to auto-increment the ID column as usual.</p>
  
  <p>Unfortunately, it appears Doctrine2 completely ignores the specified ID.</p>
  
  <hr>
  
  <p><strong>New Solution</strong></p>
  
  <p>Per recommendations below, the following is the preferred solution:</p>
  
  <pre class="lang-php prettyprint-override"><code>$this-&gt;em-&gt;persist($entity);
  
  $metadata = $this-&gt;em-&gt;getClassMetaData(get_class($entity));
  $metadata-&gt;setIdGeneratorType(\Doctrine\ORM\Mapping\ClassMetadata::GENERATOR_TYPE_NONE);
  $metadata-&gt;setIdGenerator(new \Doctrine\ORM\Id\AssignedGenerator());
  </code></pre>
  
  <p><strong>Old Solution</strong></p>
  
  <p>Because Doctrine pivots off of the ClassMetaData for determining the generator strategy, it has to be modified after managing the entity in the EntityManager:</p>
  
  <pre class="lang-php prettyprint-override"><code>$this-&gt;em-&gt;persist($entity);
  
  $metadata = $this-&gt;em-&gt;getClassMetaData(get_class($entity));
  $metadata-&gt;setIdGeneratorType(\Doctrine\ORM\Mapping\ClassMetadata::GENERATOR_TYPE_NONE);
  
  $this-&gt;em-&gt;flush();
  </code></pre>
  
  <p>I just tested this on MySQL and it worked as expected, meaning Entities with a custom ID were stored with that ID, while those without an ID specified used the <code>lastGeneratedId() + 1</code>.</p>