У меня есть две сущности с именами UserCode и Question, которые связаны между столбцами вопросов, и когда я запускаю doctrine:schema:validate, все в порядке
но моя проблема в том, когда я добавляю
@ORM\Entity(repositoryClass = "AppBundle\Repository\UserCodeRepository")
в верхней части объекта UserCode я получаю эту ошибку !!
* The association AppBundle\Entity\UserCode#question refers to the inverse side field AppBundle\Entity\Question#question which is not defined as association.
* The association AppBundle\Entity\UserCode#question refers to the inverse side field AppBundle\Entity\Question#question which does not exist.
Сущность вопроса:
<?php
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use AppBundle\Entity\UserCode;
/**
* Question
*
* @ORM\Table(name = "question")
* @ORM\Entity(repositoryClass = "AppBundle\Repository\QuestionRepository")
*/
class Question
{
/**
* @var int
*
* @ORM\Column(name = "id", type = "integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy = "AUTO")
*/
private $id;
/**
* @var string
*
* @ORM\Column(name = "question", type = "text")
* @ORM\OneToMany(targetEntity = "AppBundle\Entity\UserCode", mappedBy = "question")
*/
private $question;
/**
* Get id
*
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* Set question
*
* @param string $question
*
* @return Question
*/
public function setQuestion($question)
{
$this->question = $question;
return $this;
}
/**
* Get question
*
* @return string
*/
public function getQuestion()
{
return $this->question;
}
}
и это моя сущность UserCode:
<?php
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\ORM\Mapping\JoinColumn;
use Symfony\Component\Validator\Constraints as Assert;
/**
* UserCode
*
* @ORM\Table(name = "user_code")
* @ORM\Entity(repositoryClass = "AppBundle\Repository\UserCodeRepository")
*/
class UserCode
{
/**
* @var int
* @ORM\Column(name = "id", type = "integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy = "AUTO")
*/
private $id;
/**
* @ORM\ManyToOne(targetEntity = "AppBundle\Entity\Question", inversedBy = "question")
* @ORM\JoinColumn(name = "question", referencedColumnName = "id")
*/
private $question;
/**
* Get id
*
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* Set question
*
* @param \AppBundle\Entity\Question $question
*
* @return UserCode
*/
public function setQuestion(\AppBundle\Entity\Question $question = null)
{
$this->question = $question;
return $this;
}
/**
* Get question
*
* @return \AppBundle\Entity\Question
*/
public function getQuestion()
{
return $this->question;
}
}




Удалить
@ORM\JoinColumn(name = "question", referencedColumnName = "id")
из Сущность UserCode и
* @var string
*
* @ORM\Column(name = "question", type = "text")
от сущности вопроса он будет работать отлично :)