Convert database tables to entity classes

Source: Internet
Author: User

From the discussion of the database at the beginning of the month to the present, from changing the design principles to improving the details, this afternoon finally finalized the final database, the next step is to build a UML diagram, first, we need to create an entity class that corresponds to a database table. There are a total of 50 tables in the database. Do we need to compare the tables one by one? Who is so stupid? Well, I did that before.

Is there a simple and feasible method? Programmers certainly need to repeat code, but after that, they should use their talents in design, rather than repeating tedious operations over and over again. The program was originally used to solve complicated problems. As a programmer, it should not do the same thing again. The first thought was to write a program on your own. However, if you encounter many problems such as reading data types and your current level is insufficient, you should first "stand on the shoulders of giants" and finally find a software: entityscodegenerate. Thank you for sharing your ideas.

It is also very convenient to use. Choose database> database string> output location> output item> output language> comment content> to generate code:

The result is as follows:

If you just want to get the corresponding entity class, this is enough, but it is often the case that you need to import the modeling tool as part of the architecture. Before that, the problem was, the generated class file name is definitely not actually needed. Even if the file name is changed, the class name will not change ...... The most important step is to solve the problem. The remaining steps are details: You can use stress to modify file names in batches; you can import them to vs to replace Class names in batches ......

Now we can use the reverse engineering of EA to convert it to a class diagram:

The result is as follows:

I still remember that I used less than 40 tables to draw entity classes based on the database for nearly one morning. This method generally takes less than 10 minutes, and the entity class has a class diagram, use your creativity in design!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.