从现有数据库生成实体时出现无效参数异常


Invalid Argument Exception when generating Entities from existing database

我正在将Symfony 2项目从Propel转换为Doctrine,并希望将现有数据库转换为Doctrine实体。

要做到这一点,我遵循Symfony网站上的教程,但是当我运行以下命令:

php app/console doctrine:mapping:convert xml ./src/Acme/BlogBundle/Resources/config/doctrine/metadata/orm --from-database --force

我立即收到以下错误:

[InvalidArumentException]
Doctrine ORM Manager named "" does not exist.

谁能解释我哪里出错了,我怎么去解决这个问题?

终于找到了导致错误的原因。看来学说配置设置在配置。yml需要一个名为auto_mapping: true的参数。

例如:

doctrine:
    dbal:
        driver:   "%database_driver%"
        host:     "%database_host%"
        dbname:   "%database_name%"
        user:     "%database_user%"
        password: "%database_password%"
    orm:
        auto_mapping: true

更多信息可以在这里找到:http://symfony.com/doc/2.0/reference/configuration/doctrine.html