T4 Context Generation

Category: visual studio visualiaztion

Question

cbertrand78 on Tue, 11 Apr 2017 09:35:09


Hi all,

So, I'm using Entity Framework to do a reverse engineer of an existing database.  It's pretty complex, with references galore.  There are several Associative/Junction tables that define parent/child relationships for entries in the same table - e.g.

WorkflowStep
PK
Name

1, Step1
2, Step2

WorkflowStep_PreRequisite
WorkflowStepNodeFK
WorkflowStepPreRequisiteFK

2, 1

So - when I use EF to generate the context for this, it does the usual silly naming for the navigation properties- i.e.

WorkflowStep
WorkflowStep_PreRequisite1
WorkflowStep_PreRequisite2

Now - I have enhanced the T4 (.tt) file that produces the object model to give a nice navigation property - e.g.
ParentWorkflowStep
PreRequisiteWorkflowStep

But this nice naming convention does not make it to the diagram in the .edmx file.  So my question is this - what do I need to do to get the edmx diagram to reflect these naming changes?  I've looked in the Context.tt file and tried to replicate my previous changes, but I cannot find where the naming happens.

Thanks for all your help in advance.

Many thanks,
Chris.