Sunday, 13 October 2019

Entity Framework

public class DisplayGroup
    {
 
        [Column("ID")]
        public int ID { get; set; }

[Column("PERTINENCE_GRP_ID")]
        public int? PertinenceGroupID { get; set; }

public virtual PertinenceGroup PertinenceGroup { get; set; }

}

public class DisplayGroupContent
{

[Column("ID")]
public int ID { get; set; }


[Column("PARENT_GROUP_ID")]
public int ParentGroupID { get; set; }


public virtual DisplayGroup ParentGroup { get; set; }

}

public class PertinenceGroup
{
[Column("ID")]
public int ID { get; set; }

public virtual ICollection<DisplayGroup> DisplayGroups { get; set; }

}


public class DisplayGroupConfiguration: EntityTypeConfiguration<DisplayGroup>
{

public DisplayGroupConfiguration()
{
ToTable("GDD_ENTITY_DSPLY_GRPS");
HasKey(x => x.ID);

HasMany(x => x.DisplayGroupContents).WithRequired(x => x.ParentGroup).HasForeignKey(x => x.ParentGroupID);

HasOptional(x => x.PertinenceGroup).WithMany().HasForeignKey(x => x.PertinenceGroupID);
}
}

public class DisplayGroupContentConfiguration : EntityTypeConfiguration<DisplayGroupContent>
{

public DisplayGroupContentConfiguration()
{
{
ToTable("GDD_DSPLY_GRP_CONTENTS");
HasKey(x => x.ID);

HasRequired(x => x.ParentGroup).WithMany().HasForeignKey(x => x.ParentGroupID);

}
}
}

public class PertinenceGroupConfiguration : EntityTypeConfiguration<PertinenceGroup>
{

public PertinenceGroupConfiguration() {
ToTable("GDD_PERTINENCE_GRPS");
HasKey(x => x.ID);

HasMany(x => x.DisplayGroups)
.WithOptional(x => x.PertinenceGroup)
.HasForeignKey(x => x.PertinenceGroupID);
}
}



CREATE TABLE "CSNCFG"."GDD_ENTITY_DSPLY_GRPS"
   ( "ID" NUMBER NOT NULL ENABLE,

"OWNER_TYPE_ID" NUMBER NOT NULL ENABLE,

"PERTINENCE_GRP_ID" NUMBER(10,0),

CONSTRAINT "GDD_ENTITY_DSPLY_GRPS_PK" PRIMARY KEY ("ID")

CONSTRAINT "GDD_ENTITY_DSPLY_GRPS_FK2" FOREIGN KEY ("PERTINENCE_GRP_ID")
  REFERENCES "CSNCFG"."GDD_PERTINENCE_GRPS" ("ID") ENABLE,

   )


CREATE TABLE "CSNCFG"."GDD_DSPLY_GRP_CONTENTS"
   ( "ID" NUMBER(10,0) NOT NULL ENABLE,

"PARENT_GROUP_ID" NUMBER(10,0) NOT NULL ENABLE,

"CHILD_GROUP_ID" NUMBER(10,0),

CONSTRAINT "GDD_DSPLY_GRP_CONTENTS_PK" PRIMARY KEY ("ID")

CONSTRAINT "GDD_DSPLY_GRP_CONTENTS_FK1" FOREIGN KEY ("PARENT_GROUP_ID")
  REFERENCES "CSNCFG"."GDD_ENTITY_DSPLY_GRPS" ("ID") ENABLE,

CONSTRAINT "GDD_DSPLY_GRP_CONTENTS_FK2" FOREIGN KEY ("CHILD_GROUP_ID")
  REFERENCES "CSNCFG"."GDD_ENTITY_DSPLY_GRPS" ("ID") ENABLE,

   )



 CREATE TABLE "CSNCFG"."GDD_PERTINENCE_GRPS"
   ( "ID" NUMBER(10,0),

CONSTRAINT "GDD_PERTINENCE_GRPS_PK" PRIMARY KEY ("ID")

   ) 

No comments:

Post a Comment