I want to generate entity classes from a database for my symfony application.
So I followed the following three steps (From How to generate Entities from an Existing Database)
1. php app/console doctrine:mapping:convert yml ./src/Acme/BlogBundle/Resources/config/doctrine/metadata/orm --from-database --force
2. php app/console doctrine:mapping:import AcmeBlogBundle yml
3. php app/console doctrine:generate:entities AcmeBlogBundle
For knowing the working of these three commands, I just removed all files from ./src/Acme/BlogBundle/Resources/config/doctrine/metadata/orm. I added one more field in one table. After that I followed command-2 and command-3.
I checked the modified table’s entity for the new field. The new field was present in the entity.
Then why should we use the doctrine:mapping:convert command in order to generate entities from an existing database?
Once you have generated your entity classes, Doctrine is intelligent enough to get all the information it needs to import the mapping from the Entity classes, not needing the class metadata obtained in your first step. If you had deleted the metadata AND the entity classes then you would not be able to run step 2 without running step 1.