Author : HASSAN MD TAREQ

Separating T4 Generated Domain Classes

  • In Visual Studio Create a new project
  • In File Explorer Move [model].tt to the new project folder
  • Back in Visual Studio, Include [model].tt in Domain Classes project
  • Delete [model].tt from data project
  • Modify [model].tt to point to correct EDMX path
  • Add a reference of domain classes project to data project (Containing DbContext)
  • Modify [context].tt to use new namespace
  • After each model modification, force code generation

Separating T4 Generated Domain Classes sreenshots

Step-1

Separating domain classes Step 1

Step-2

Separating domain classes Step 2

Step-3

Separating domain classes Step 3

Step-4

Separating domain classes Step 4

Step-5

Separating domain classes Step 5

Step-6

Separating domain classes Step 6

Step-7

Separating domain classes Step 7

Step-8

Separating domain classes Step 8

Step-9

Separating domain classes Step 9

Step-10

Separating domain classes Step 10

Step-11

Separating domain classes Step 11

Step-12

Separating domain classes Step 12

Step-13

Separating domain classes Step 13

Step-14

Separating domain classes Step 14

Step-15

Separating domain classes Step 15

Step-16

Separating domain classes Step 16

Step-17

Separating domain classes Step 17

Step-18

Separating domain classes Step 18

Step-19

Separating domain classes Step 19

Step-20

Separating domain classes Step 20

Reflecting changes to domain classes

Since we separated domain classes from data project, any change in conceptual model would not automatically be reflected into domain classes. We have to manually update domain classes every time we change conceptual model

Step-1

Reflecting conceptual model changes to domain classes Step 1

Step-2

Reflecting conceptual model changes to domain classes Step 2

Step-3

Reflecting conceptual model changes to domain classes Step 3

Step-4

Reflecting conceptual model changes to domain classes Step 4

Step-5

Reflecting conceptual model changes to domain classes Step 5