G
G
gitdev2018-09-26 10:26:36
symfony
gitdev, 2018-09-26 10:26:36

How to make primary key from two columns in Symfony 4?

Throws an error:
No identifier/primary key specified for Entity "App\Metrag\AppBundle\Entity\AgentRealty". Every Entity must have an identifier/primary key.

/**
 * AgentRealty
 *

 * @ORM\Entity
 *
 */
class AgentRealty
{
    /**
     * @ORM\OneToOne(targetEntity="App\Metrag\AppBundle\Entity\Realty")
     * @ORM\JoinColumn(name="realty_id", referencedColumnName="id" )
     */
    private $realty;

    /**
     * @ORM\OneToOne(targetEntity="App\Metrag\AppBundle\Entity\Agent")
     * @ORM\JoinColumn(name="agent_id", referencedColumnName="id" )
     */
    private $agent;
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Stanislav B, 2018-09-26
@gitdev

for both, add @ORM\Id. and will be a composite key. here

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question