title: Symfony2 and Doctrine2: No identifier/primary key specified for Entity "X". Every Entity must have an identifier/primary key
body: <p>I'm using Symfony2 to create some dummy projects. I'm keeping to the Symfony2 Book documentation to create an Entity with Doctrine command line (<a href="http://symfony.com/doc/current/book/doctrine.html#add-mapping-information" rel="nofollow">http://symfony.com/doc/current/book/doctrine.html#add-mapping-information</a>). I'm using, thus, annotations, the plain entity <em>Product</em> and no associations.</p>
  
  <p>I've copied the exact example: I've successfully created the database and created the table Product. Then, I've removed everything and tried to recreate the database (everything's fine) and the table (problem!), that just for testing purposes.
  Doctrine can't generate any more getters and setters and can't create the table on the MySQL database.</p>
  
  <p><strong>Here some output</strong></p>
  
  <pre><code>app/console doctrine:generate:entities MyBundle
  
  &gt; backing up Product.php to Product.php~
  &gt; generating MyBundle\Entity\Product
  
  (nothing happens except for creating the identical backup file with no setters / getters added)
  </code></pre>
  
  <p>-</p>
  
  <pre><code>app/console doctrine:schema:validate
  OR
  app/console doctrine:schema:create
  OR
  app/console doctrine:schema:update --force
  ----------
  [Doctrine\ORM\Mapping\MappingException]
  No identifier/primary key specified for Entity "MyBundle\Entity\Product".
  Every Entity must have an identifier/primary key.
  
  doctrine:schema:validate [--em[="..."]]
  </code></pre>
  
  <p><strong>My Architecture</strong></p>
  
  <pre><code>PHP          5.5.21 (tried also with PHP 5.5.14)
  Apache       2.4.9
  Mac OSX      10.10.1 - Yosemite
  MySQL        5
  ENV          dev
  </code></pre>
  
  <p><strong>Composer installed packages</strong></p>
  
  <pre><code>doctrine/annotations                 v1.2.3  Docblock Annotations Parser
  doctrine/cache                       v1.4.0  Caching library offering an object-oriented API for many cache backends
  doctrine/collections                 v1.2    Collections Abstraction library
  doctrine/common                      v2.4.2  Common Library for Doctrine projects
  doctrine/dbal                        v2.5.1  Database Abstraction Layer
  doctrine/doctrine-bundle             v1.3.0  Symfony DoctrineBundle
  doctrine/doctrine-cache-bundle       v1.0.1  Symfony2 Bundle for Doctrine Cache
  doctrine/inflector                   v1.0.1  Common String Manipulations with regard to casing and singular/plural rules.
  doctrine/lexer                       v1.0.1  Base library for a lexer that can be used in Top-Down, Recursive Descent Parsers.
  doctrine/orm                         v2.4.7  Object-Relational-Mapper for PHP
  incenteev/composer-parameter-handler v2.1.0  Composer script handling your ignored parameter file
  jdorn/sql-formatter                  v1.2.17 a PHP SQL highlighting library
  kriswallsmith/assetic                v1.2.1  Asset Management for PHP
  monolog/monolog                      1.12.0  Sends your logs to files, sockets, inboxes, databases and various web services
  psr/log                              1.0.0   Common interface for logging libraries
  sensio/distribution-bundle           v3.0.15 Base bundle for Symfony Distributions
  sensio/framework-extra-bundle        v3.0.4  This bundle provides a way to configure your controllers with annotations
  sensio/generator-bundle              v2.5.1  This bundle generates code for you
  sensiolabs/security-checker          v2.0.1  A security checker for your composer.lock
  swiftmailer/swiftmailer              v5.3.1  Swiftmailer, free feature-rich PHP mailer
  symfony/assetic-bundle               v2.6.0  Integrates Assetic into Symfony2
  symfony/monolog-bundle               v2.7.1  Symfony MonologBundle
  symfony/swiftmailer-bundle           v2.3.8  Symfony SwiftmailerBundle
  symfony/symfony                      v2.6.3  The Symfony PHP framework
  twig/extensions                      v1.2.0  Common additional features for Twig that do not directly belong in core
  twig/twig                            v1.18.0 Twig, the flexible, fast, and secure template language for PHP
  </code></pre>
  
  <p><strong>My Code</strong></p>
  
  <p>My code is exactly as in the Symfony2 Book documentation except for the Bundle name, changed to MyBundle. The structure of files and folders is working properly with other features. There are no particular settings for the project, just the basics.</p>
  
  <pre><code>namespace MyBundle\Entity;
  
  use Doctrine\ORM\Mapping as ORM;
  
  /**
   * @ORM\Entity
   * @ORM\Table(name="product")
   */
  class Product
  {
      /**
       * @ORM\Column(type="integer")
       * @ORM\Id
       * @ORM\GeneratedValue(strategy="AUTO")
       */
      protected $id;
  
      /**
       * @ORM\Column(type="string", length=100)
       */
      protected $name;
  
      /**
       * @ORM\Column(type="decimal", scale=2)
       */
      protected $price;
  
      /**
       * @ORM\Column(type="text")
       */
      protected $description;
  }
  </code></pre>
  
  <hr>
  
  <p><strong>Already tried to</strong></p>
  
  <ul>
  <li>Change project permissions</li>
  <li>Execute "app/console doctrine:generate:entities" as root</li>
  <li>Clear the cache
  <ul>
  <li>Execute <em>cache:clear</em> and <em>cache:warmup</em></li>
  <li>Manually remove the cache folder</li>
  </ul></li>
  <li>Keep just the id (as primary key) in the Product entity</li>
  <li>Remove and recreate the whole database</li>
  <li>Remove Product Entity, clear the cache and recreate everything (manually)</li>
  <li>Update all the vendors</li>
  <li>Checked all the double ** for the annotations</li>
  <li>Change computer with the same software architecture</li>
  <li>I've also executed (thanks @Srdjan)
  php app/console doctrine:cache:clear-metadata &amp;&amp; app/console doctrine:cache:clear-query &amp;&amp; app/console doctrine:cache:clear-result
  but getters and setters are not generated</li>
  <li>I've removed the table, database and recreated step by step (thanks @paistra)</li>
  <li><p>I've tried to remove the table with</p>
  
  <p>app/console doctrine:schema:drop</p></li>
  </ul>
  
  <p>but the error is always the same</p>
  
  <pre><code>[Doctrine\ORM\Mapping\MappingException]
  No identifier/primary key specified for Entity "MyBundle\Entity\Product".
  Every Entity must have an identifier/primary key.
  </code></pre>
  
  <p>even if the table doesn't exist..</p>
  
  <hr>
  
  <p>Thank you for your help</p>