假设我有2个实体。卡和用户。 用户在UserBundle和Card是PublicBundle。
在用户中我有这个功能:
#namespace Kanban\UserBundle\Entity;
/**
* Add assignment
*
* @param \Kanban\PublicBundle\Entity\Card $assignment
* @return User
*/
public function addAssignment(\Kanban\PublicBundle\Entity\Card $assignment)
{
$this->assignment[] = $assignment;
return $this;
}
每次执行此命令时:
php app/console doctrine:schema:update --dump-sql
它抛出了这个错误:
[Doctrine\ORM\Mapping\MappingException]
The target-entity Kanban\UserBundle\Entity\Card cannot be found in 'Kanban\UserBundle\Entity\User#assignm
ent'.
我试过这句话:
use Kanban\PublicBundle\Entity;
use Kanban\PublicBundle\Entity\Card;
在文件的开头但显示相同的错误。 关于我做错了什么想法?
答案 0 :(得分:1)
NM!,
orm.yml文件出现问题,已更改:
manyToMany:
assignment:
targetEntity: Card
cascade: { }
mappedBy: customer
inversedBy: null
joinTable: null
orderBy: null
到
manyToMany:
assignment:
targetEntity: Kanban\PublicBundle\Entity\Card
cascade: { }
mappedBy: customer
inversedBy: null
joinTable: null
orderBy: null
这解决了这个问题!