sjh37 / EntityFramework-Reverse-POCO-Code-First-Generator

EntityFramework Reverse POCO Code First Generator - Beautifully generated code that is fully customisable. This generator creates code as if you reverse engineered a database and lovingly created the code by hand. It is free to academics (you need a .edu or a .ac email address), not free for commercial use. Obtain your licence from
https://www.reversepoco.co.uk/
Other
700 stars 230 forks source link

Wiki: Table Per Type, EF core #775

Closed fasteddys closed 1 year ago

fasteddys commented 1 year ago

Hello Simon, I am trying to learn your cool tool, my goal is to see if I can use it regularly to reverse the DB; make updates to the DB tables; and then reflect those chance back to the DB.

I tried the this so far, I first reversed an pre/existing db table ->Engine table. Second, in my middleware I added new inherited objects like Car, Auto, Rickshaw which inherit from my Engine Poco, I dont know how to do table per types with your tool and persist them back to DB?

Can you please help, I searched your wiki and was not able to find my way, in your code how do I do the following

  1. How to setup/add/update/enhance Table Per Type or Hierarchy, with inherited types in my middleware, for e.g. Engine-> inside ReversePOCO how can I setup the new models Car, Auto, Rickshaw etc. as Table per Types

  2. Once I make those changes, how do I reflect the new updates from the Reverse Poco Model to the database? is there an some switch or option to run add-migration; and update database, from ReversePOCO once I make the updates, or is something I have to do manually outside?

sjh37 commented 1 year ago

Hi @fasteddys You are using the tool incorrectly. The changes should be made first to the database directly, using CREATE TABLE etc. Then simply press Save (ctrl-s) on your <database>.tt file and that will create your new POCOs for you automatically.

Each time the database is changed, press save on your .tt file to have the generator create the classes you need.

This generator reads the database schema and creates POCOs for you. It does not work the other way around where it creates tables in the database.

fasteddys commented 1 year ago

Thanks @sjh37 I was able to generate the Poco, but how do I refactor the generated to look like TPer type concrete tables.