0 votes

Inspired by a customers inquiry on email:

There is a crucial point, that is blocking my work with ORM Designer:

  1. I build my database schema with MySQL Workbench
  2. Then i imported the .mwb file into ORM Designer
  3. All entities was imported with underscore style (because are defined like that at the DB, and i would like to keep them how they are)
  4. Then i renamed all Entities from underscore to camel case:
    user_addresses -> UserAddress and so on
  5. ORM Designer now doesn't know that UserAddress actualy is user_addresses (despite that Doctrine2 knows becouse it's described in its anotation), and when a tried to synchronize my .mwb to ORM Designer, i have two Entities for one table:

Table: useraddresses
Entities:
- user
addresses: which is up to date
- UserAddress: which it's not up to date

So far, the only possibility that i get it's just to stop using MySQL Workbench, and to use only ORM Designer because of the sync issue described above.

The way i would like to work ORM Designer is to recognize that i already have an entitiy which represents a table, and to update this entity instead of creating a new one.If i can achieve this behavior with ORM Designer, i can continue use both ORM Designer and MySQL Workbench, otherwise i have to stop using one of them,which my opinion it's very pitty.

asked in How To & Manuals by Skipper developer (74.9k points)
edited by

1 Answer

0 votes
Best answer

Usually, to create and modify database only ORM
Designer and built-in Doctrine 2 functions are sufficient (and you can
stop using Workbench or at least use it separately).

The ORM point of view does not "care about the DB", it just assumes some DB is used and focuses on entities and their relations. Though DB can be configured by Doctrine2 (to a degree using the ORM properties), it might not be enough for everybody.

The problem is the MWB does not handle the abstraction layer at all, so it is not possible to integrate it to a single continuous workflow (DB to MWB to ORM Designer and vice versa). You can import the MWB schema for the first time so it is easier to start using ORM Designer on your existing projects. After first import, MySQL Workbench and ORM Designer have to be kept separate.

The import from MWB is best used as a single time measure, to convert
your standing changes to ORM Designer project and then you convert
your definition files do database (and back) using the Doctine 2
schema-tool and convert-mapping commands. Because MySQL Workbench
does not support ORM properties, you could lose lot of your work on
each import from the database, if you used MWB in each import of the
changes of the database.

So the recommended workflow would be:

A) First time import of the project you already have in MySQL Workbench:
1)Import the MWB file to ORM Designer
2)Edit the model and export the definition files using ORM Designer
3)Project the definition files to databasue using Doctrine commands

B)Any subsequent modifications of the database:
1)Generate definition files from the DB using Doctrine
2)Import the definitions files to ORM Designer project, all attributes
will properly merge
4)Edit the project and export changes
2)Update the database using Doctrine commands

So you can keep administering the DB with MySQL anytime you need to
make direct changes using MySQL Workbench, you can generate new
definition files using Doctrine and import these to ORM Designer.

This is also the only way how to keep separate names for your entities
in your model (UserAddresses) and database (user_addresses), because
these are handled by ORM properties, and as I mentioned before MySQL
Workbench does not support these. On the other hand this can be
handled by ORM Designer quite easily, just define your entity as shown
on the screenshot:
http://i.imgur.com/NzhuDbz.png

Also renaming of the entities might be getting a little easier by
using templates (by using the on-update template you can automatically
generate the table name from the entity name):
http://help.orm-designer.com/en/extending-templates

The template similar to one you need is in our template library under
the example number 3:
http://help.orm-designer.com/en/template-library

answered by Skipper developer (74.9k points)
selected by