Using Symfony 4.1, Sonata User Bundle 4.x, and FOSUserBundle 2.1.2.
I am trying to override the table names for the User and Group tables. I therefore added annotations to the auto generated user and group classes:
use Sonata\UserBundle\Entity\BaseGroup as BaseGroup;
use Doctrine\ORM\Mapping as ORM;
/**
* This file has been generated by the SonataEasyExtendsBundle.
* @ORM\Entity()
* @ORM\Table(name="aegis_group")
* @link https://sonata-project.org/easy-extends
* References:
* @link http://www.doctrine-project.org/projects/orm/2.0/docs/reference/working-with-objects/en
*/
class Group extends BaseGroup
{
/**
* @ORM\Id
* @var int $id
*/
protected $id;
/**
* Get id.
*
* @return int $id
*/
public function getId()
{
return $this->id;
}
}
I then modified doctrine.yaml to factor in these annotations:
mappings:
App:
is_bundle: false
type: annotation
dir: '%kernel.project_dir%/src/Entity'
prefix: 'App\Entity'
alias: App
FOSUserBundle: ~
ApplicationSonataUserBundle:
type: annotation
SonataUserBundle: ~
However, when I run migrations, doctrine gives me an error:
In MappingException.php line 46:
No identifier/primary key specified for Entity "App\Application\Sonata\User Bundle\Entity\Group" sub class of "Sonata\UserBundle\Entity\BaseGroup". Every Entity must have an identifier/primary key.
How to fix this issue, so that I can use my own custom table names ? All I want to do is to change the database table names, this should not be this involved.