locked
EF Inheritance(Table per Type) model RRS feed

  • Question

  • Hello,
    I am facing some problem with using EF Inheritance. Just to simplify my problem -- say,
    I have a table Person(ID) and another table Employee(ID,Name,Designation).
    Employee(ID) references Person(ID).

    I am able to model this using EF Inheritance(Table per Type) model.

    But say If I have one more column in Employee called ManagerID.
    Employee(ID,Name,Designation,ManagerID) with Employee(ManagerID) references Employee(ID).

    Is it possible to model this using EF Inheritance(Table per Type) model wherein I will be having ID only in the Person class.

    Thanks
    Sharath

    Wednesday, November 19, 2008 7:15 AM

Answers

  • I think that it is possible, because in the mapping really (physically in the storage model) you have the foreign key imported in to Employee referred to the Person ID.

     

    Try to create a 0...1 --> 1 association from Employee to Employee

    in Mapping Details:

    Maps to EEmployee

    - EEmployee ID Person <--> ManagerID

    - EEmployee1 ID Person <--> ID (that is the foreign ID of Person contains in Employee table)

    Wednesday, November 19, 2008 9:31 AM

All replies

  • I think that it is possible, because in the mapping really (physically in the storage model) you have the foreign key imported in to Employee referred to the Person ID.

     

    Try to create a 0...1 --> 1 association from Employee to Employee

    in Mapping Details:

    Maps to EEmployee

    - EEmployee ID Person <--> ManagerID

    - EEmployee1 ID Person <--> ID (that is the foreign ID of Person contains in Employee table)

    Wednesday, November 19, 2008 9:31 AM
  • Thanks a lot.

    Wednesday, November 19, 2008 4:34 PM