ManyToOne 关系上的 Doctrine MappingException

Doctrine MappingException on ManyToOne relationship

我正在努力创建两个实体之间的 ManyToOne 关系。根据文档,我的代码应该足以创建有效的 ManyToOne 关系,但我不断收到如下所述的错误。我一定是遗漏了一些明显的东西,但我不确定是什么。

项目有很多 RemoteVotes。

应用程序抛出的错误是:

Doctrine\ORM\Mapping\MappingException
The target-entity App\Model\RemoteVote cannot be found in 'App\Model\Project#remoteVotes'.

RemoteVote.php模型的相关部分:

   namespace App\Model;

   /**
    * @ORM\Entity
    * @ORM\Table(name="remote_votes")
    */
    class RemoteVote extends BaseEntity {

    ...

   /**
     * @ORM\ManyToOne(targetEntity="Project", inversedBy="remoteVotes")
     * @ORM\JoinColumn(name="project_id", referencedColumnName="id")
     */
    protected $project;

   ...

Project.php型号的相关位:

namespace App\Model;

/**
 * @ORM\Entity
 * @ORM\Table(name="projects")
 */
class Project extends BaseEntity
{

    public function __construct()
    {
        $this->remoteVotes = new ArrayCollection();
    }

    ...


    /**
     * @ORM\OneToMany(targetEntity="RemoteVote", mappedBy="project", cascade={"persist"})
     */
    protected $remoteVotes;

    ...

提前致谢。

遗憾的是,这不是 Doctrine 问题,而是框架的缓存问题。删除缓存解决了它。