Symfony:如何验证学说实体映射的一致性

Symfony: how to verify doctrine entities mapping consistency

浏览我使用 Symfony 构建的应用程序时,我发现某些实体的某些映射不一致。

Symfony Profiler 告诉我:

AppBundle\Entity\Email The mappings AppBundle\Entity\Email#forCustomer and AppBundle\Entity\Customer#emails are inconsistent with each other.

并且反过来:

AppBundle\Entity\Customer The association AppBundle\Entity\Customer#emails refers to the owning side field AppBundle\Entity\Email#owner which does not exist.

如何一次性检查所有实体以发现这种不一致,而不必浏览所有应用程序以期发现其他不一致?

对于 Symfony 版本 低于 3.4 你可以试试:

app/console doctrine:schema:validate

对于 Symfony 3.44.*:

bin/console doctrine:schema:validate