class Media extends BaseMedia /** * @var Specialists * * @ORM\ManyToOne(targetEntity="Specialists", inversedBy="images") * @ORM\JoinColumns({ * @ORM\JoinColumn(name="spec", referencedColumnName="id") * }) */ private $spec; class Specialists /** * @var Media * * @ORM\OneToMany(targetEntity="Application\Sonata\MediaBundle\Entity\Media", mappedBy="spec") * @ORM\JoinColumns({ * @ORM\JoinColumn(name="images", referencedColumnName="id") * }) */ private $images; 

After php app / console, doctrine: schema: validate gives an error

[Mapping] FAIL - The entity-class 'Specialists \ SpecialistsBundle \ Entity \ Specialists' mapping is invalid: * The association Specialists \ SpecialistsBundle \ Entity \ Specialists # images refers to the \ Sonata \ MediaBundle \ Entity \ Media # spec which does not exist.

took an answer with symfony sonata media bundle add images / videos to a user

I will be grateful for the answer

    1 answer 1

    You have a namespace in OtM annotations Media::$spec skipped. Maybe this is the problem?