none
EF class auto-generation question RRS feed

  • Question

  • Does anyone know if this is possible?

      I have four existing entities E1,E2,E3,E4 which were autogenerated by EF.  Now I want to create a POCO object that contains all of the fileds of each but I'd like to do it via auto-generation features of EF.  The questions are:

    1. Is there anyway to stack these in a super class which uses an inheritance chain of the four entities?
    2. If instead I attempt to pass them in a super class as interfaces, is there any way to get the T4 template to access them and generated all the properties in the super class?

    JP Cowboy Coders Unite!


    Friday, September 5, 2014 9:50 PM

Answers

  • Hello Javaman,

    >>1.Is there anyway to stack these in a super class which uses an inheritance chain of the four entities?

    From your description, it seems that you are working with database first approach. If I am correct, then you could follow this walkthrough to create a TPH inheritance model using database first approach.

    >>2.If instead I attempt to pass them in a super class as interfaces, is there any way to get the T4 template to access them and generated all the properties in the super class?

    As far as I know, the current template is designed to generate an entity class which contains only the correspondent columns, for achieving what you want, you might need to customize the T4 template while I think it should be complex and not easy to be implemented.

    Best Regards,

    Fred.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Monday, September 8, 2014 3:16 AM
    Moderator