none
EF Code First - Issue with a mix of TPT and TPC RRS feed

  • Question

  • Hi,

        I have a AuditableEntity(a complex Type by default - having no primary key) as follows -

      public class AuditableEntity
        {
            public String CreatedByUserId { get; set; }
            public DateTimeOffset CreatedOnDateTime { get; set; }
            public String LastModifiedUserId { get; set; }
            public DateTimeOffset LastModifiedDateTime { get; set; }

        }

    Also I have a BaseEntity as follows -

    public abstract class BaseEntity
        {
            public Boolean IsActive{ get; set; }
            public AuditableEntity AuditInfo{get;set;}

        }

    Now I have Derived Classes as follows -

    public class Derived1 : BaseEntity
        {
            public String Property1{get;set;}

        }

    public class Derived2 : Derived1
        {
            public String Property2{get;set;}

        }

    public class Derived3 : Derived1
        {
            public String Property3{get;set;}

        }

    Now I want 3 tables to be formed viz. Derived1,Derived2,Derived3 where

    derived1 will have columns - Property1, IsActive,CreatedByUserId ,CreatedOnDateTime,LastModifiedUserId  and LastModifiedDateTime

    derived2 will have columns - Property2, IsActive,CreatedByUserId ,CreatedOnDateTime,LastModifiedUserId  and LastModifiedDateTime

    derived3 will have columns - Property3, IsActive,CreatedByUserId ,CreatedOnDateTime,LastModifiedUserId  and LastModifiedDateTime

    It seems a mix of TPT and TPC.Please suggest some solution.

    Thursday, April 11, 2013 5:58 PM

Answers