Generating a single Entity from existing database using symfony2 and doctrine

I had the same problem, you’ve to do this way:

php app/console doctrine:mapping:convert metadata_format \
    ./src/App/MyBundle/Resources/config/doctrine \
    --from-database \
    --filter="Yourtablename"

Then

php app/console doctrine:mapping:import AppMyBundle \
    metadata_format --filter="Yourtablename"

Where metadata_format is the file ending you want to generate (e.g. xml, yml, annotation)

And finally

php app/console doctrine:generate:entities AppMyBundle --no-backup

Like this doctrine will load only the entity you need. Just be carefull on the filter you must use the CamelCase !

Hope this will help you

Leave a Comment