I got an error when I'm trying generate table for ManyToMany relation.
In these two entities I have the ManyToMany relationship, and when I'm running make:migration command I got error 'Column name FCO_ID
referenced for relation from App\Entity\CINFO\CiRome towards App\Entity\CINFO\CiFormacode does not exist'.
I don't understand what I'm doing wrong, it's exactly like in doctrine documentation. https://www.doctrine-project.org/projects/doctrine-orm/en/2.6/reference/association-mapping.html#many-to-many-unidirectional.
My id's names are not 'id', but I defined them in the JoinColumns of ManyToMany relationship.
/**
* @ORM\Entity(repositoryClass=CiFormacodeRepository::class)
* @ORM\Table(name="ci_formacode", indexes={
* @Index(name="FCO_CODE", columns={"FCO_CODE"})
* })
*/
class CiFormacode
{
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer", name="FCO_ID")
*/
private $FCO_ID;
/**
* @ORM\ManyToOne(targetEntity=CiFormacode::class, inversedBy="ciFormacodes")
* @JoinColumn(name="FCO_PERE_ID", referencedColumnName="FCO_ID", nullable=true)
*/
private $FCO_PERE;
/**
* @ORM\ManyToMany(targetEntity=CiRome::class, mappedBy="FCO")
* @ORM\JoinTable(name="ci_fcorome", joinColumns={@JoinColumn(name="ROME_ID", referencedColumnName="rome_id")})
*/
private $ciRomes;
}
/**
* @ORM\Entity(repositoryClass=CiRomeRepository::class)
* @ORM\Table(name="ci_rome")
*/
class CiRome
{
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer", name="rome_id")
*/
private $rome_id;
/**
* @ORM\ManyToOne(targetEntity=CiRomeDp::class, inversedBy="ciRomes")
* @JoinColumn(name="romedp_id", referencedColumnName="romedp_id", nullable=true)
*/
private $romedp;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $rome_code;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $rome_lib;
/**
* @ORM\OneToMany(targetEntity=CiRomeAppelation::class, mappedBy="ROME")
*/
private $ciRomeAppelations;
/**
*
* @ManyToMany(targetEntity="App\Entity\CINFO\CiFormacode")
* @JoinTable(name="ci_fcorome",
* joinColumns={@JoinColumn(name="FCO_ID", referencedColumnName="FCO_ID")},
* inverseJoinColumns={@JoinColumn(name="rome_id", referencedColumnName="rome_id")}
* )
*/
private $FCO;
}
Thanks for your help!
@JoinColumn
– simon.ro