Explicitly set Id with Doctrine when using “AUTO” strategy
Although your solution work fine with MySQL, I failed to make it work with PostgreSQL as It’s sequence based. I’ve to add this line to make it work perfectly : $metadata->setIdGenerator(new \Doctrine\ORM\Id\AssignedGenerator());