0

I need to import database structure from existing database. I tried with

  • doctrine:mapping:import "App\Entity" annotation --path=src/Entity

  • doctrine:mapping:convert xml src/Entity --from-database --force

And I have this error : Table [tableName] has no primary key

So I would import only tables than I need for my project following this topic : Generating a single Entity from existing database using symfony2 and doctrine

and I have the same error.

Have you got a solution for me please?

Thanks in advance.

2 Answers2

1

You can add a 'schema_filter' on the Dbal to only have the doctrine:mapping:import 'see' (or avoid reading from) specific table names.

doctrine:
    dbal:
        connections:
            user_db:
                # only use for `bin/console doctrine:mapping:import`
                schema_filter: /^(oauth_)/
    orm: # configs...
Alister Bulman
  • 34,482
  • 9
  • 71
  • 110
-1

Doctrine requires all tables to have a primary key.

If you can't add primary key to existing tables check here:

Symfony Doctrine Models for Entity Without Primary Keys

https://medium.com/@joaoneto/solves-doctrine-orm-error-with-tables-without-primary-key-on-mysql-when-mapping-the-database-1ce740610b51