Search code examples
phpdoctrine-ormdoctrinesymfony1

Symfony Doctrine Models for Entity Without Primary Keys


I'm working with a legacy database while re-building the web application. I want to use Symfony2.x which obviously has Doctrine as ORM.

I've around 50 (mysql) tables which has NO Primary Keys. When I try to generate models, it does not let me do and throw an exception with "No Primary Key on ... table".

Do I must have Primary Keys on tables to use Doctrine or is there any way around it?

Any help would be great.

Thanks.


Solution

  • Doctrine requires every entity class to have an identifier/primary key.

    Take a look at this page: http://www.doctrine-project.org/docs/orm/2.0/en/reference/basic-mapping.html#identifiers-primary-keys