1
  1. Created POCOs using Self-Tracking Entities template
  2. Copied .tt file with POCOs to class library
  3. Added new table to database
  4. Refreshed edmx file
  5. Now what?

Do I really have to Add Code Generation Item and copy the generated POCOs to my class library again?

Obviously this will become a huge hindrance in a fast changing data model. Is there an automated way to solve this (built in way)?

Ladislav Mrnka
  • 360,892
  • 59
  • 660
  • 670
O.O
  • 11,077
  • 18
  • 94
  • 182
  • The TT files should re-generate your pocos. Not sure what you're asking here. –  Apr 10 '11 at 14:33
  • How do I get the TT file to re-generate the pocos when the TT file sits in a different project? – O.O Apr 10 '11 at 14:40
  • Is this what you're trying to do: http://stackoverflow.com/questions/2104641/entity-container-and-model-generation-in-different-assemblies –  Apr 10 '11 at 15:54

2 Answers2

1

Once you move a template to another class library you must trigger its update manually. Use context menu on .tt file and select Run custom tool.

Ladislav Mrnka
  • 360,892
  • 59
  • 660
  • 670
  • I did that on both of the .tt files, but no new files were created in the class library. (even though there is a new table in the edmx file) – O.O Apr 10 '11 at 15:18
  • Did you save EDMX file? Also make sure that path in .tt file points to the EDMX. – Ladislav Mrnka Apr 10 '11 at 15:20
  • yep. and I can run the solution and run queries, so I know the path is correct. – O.O Apr 10 '11 at 15:28
  • actually I noticed that after adding a new table through the update model dialog, the table never gets added to the design surface – O.O Apr 10 '11 at 15:39
  • OK, figured out what was happening. The test table I added didn't have a primary key and so the designer automatically commented it out so nothing was generated. After adding a table with a primary key, I did the run custom tool thing and all works. – O.O Apr 10 '11 at 16:03
0

Move (do not copy) the .tt file to other assembly, then edit it and change "inputfile" path to relative path from that assembly's directory to where the edmx is.

To update, right click, run custom tool or open .tt file and save.

Danny Varod
  • 17,324
  • 5
  • 69
  • 111