Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

T4 Generation: Where does VsNamespaceSuggestion() pull from?

Tags:

Does anybody know, in a .tt file, where code.VsNamespaceSuggestion() gets its namespace from?

I'm having an issue where I had to change a solution's namespace, and I swear I've changed it everywhere (folder names, filenames, project names, project properties, assembly info, etc). But when the .tt file runs, it always puts the old namespace back in its generated classes. I'm told it comes from the EF model, but I see nothing in there that shows a namespace (either in the designer/properties or by opening the .edmx file in NotePad).

Any thoughts? For a hack, I'm simply overriding it in the next line with the namespace I want:

string namespaceName = code.VsNamespaceSuggestion(); namespaceName = "Desired.Namespace"; //HACK: 
like image 648
James in Indy Avatar asked May 10 '11 16:05

James in Indy


Video Answer


1 Answers

Just had this exact problem, and the solution I discovered wasn't mentioned here, so I thought I'd help anyone that came across this article in a search.

Click on the code-generation *.tt file that is generating your entities. In the properties pane, set the Custom Tool Namespace to the namespace you would like generated. Mine was blank, so T4 was generating the namespace from the default project namespace + folder heirarchy.

like image 141
mattkab Avatar answered Sep 28 '22 04:09

mattkab