zelazowy
zelazowy

Reputation: 1046

How to specify id options in 'doctrine:generate:entity' command?

I'm using doctrine:generate:entity command to generate entities. I want to use guid (string(32)) instead of integer as id type, but when I specify it like id:string(32) in --fields option I get following error:

[Doctrine\ORM\Mapping\MappingException]
Duplicate definition of column 'id' on entity 'Acme\DemoBundle\Entity\Test' in a field or discriminator column mapping.

What should I do to get it working?

@answer: As @loicfavory wrote in comment to his answer the only way is to extend Sensio\Bundle\GeneratorBundle\Generator\DoctrineEntityGenerator class where id options are set manually.

Upvotes: 0

Views: 240

Answers (1)

loicfavory
loicfavory

Reputation: 837

The Id is automatically generated by the DoctrineEntityGenerator with the integer type. I think that if you specify it with the --fields option, it duplicate the creation of the field.

That's the error you got.

Did you try to change the type manually in the entity class, after the command create it ?

Upvotes: 1

Related Questions