Doctrine orm:convert-mappings errors on primary key

Doctrine error orm:convert-mappings

Doctrine orm error like above? I have been there.

The solution I am providing is not that great solution but it can keep you going for a while.

A tool for generating entities for doctrine orm from the database table without primary key might complain as:

has no primary key. Doctrine does not support reverse engineering from tables that don’t have a primary key.

From the code base search for DatabaseDriver.php file:

Go to DatabaseDriver.php

Search for reverseEngineerMappingFromDatabase method in the given file.

uncomment the the following part as follows

           //if ( ! $table->hasPrimaryKey()) {
              //  throw new MappingException(
                //    "Table " . $table->getName() . " has no primary key. Doctrine does not ".
                  //  "support reverse engineering from tables that don't have a primary key."
                //);
            //}

            //$pkColumns = $table->getPrimaryKey()->getColumns();

Add the following line

$pkColumns = array();

Then search for method getTablePrimaryKeys and comment everything inside it and return empty array.

The above method will remove the has no primary key. Doctrine does not support reverse engineering from tables that don’t have a primary key. error when using entity generation tool.