Comments in T4 Templates

To include comments as part of control code, they need to be inside a code block of some sort, for example <# // Hello this is a comment #> or <#+ // Hello this is a comment in a class feature block #> Sometimes you need to push the close tag to the next line … Read more

Improve navigation property names when reverse engineering a database

There a few things you need to change inside the .tt file. I choose to use the third solution you suggested but this requires to be formatted like FK_CollectionName_RelationName. I split them up with ‘_’ and use the last string in the array. I use the RelationName with the ToEndMember property to create a property … Read more

How can I use Linq in a T4 template?

By default in Visual Studio 2008 (and as used in most online examples) the template is compiled with the 2.0 Framework, which does not include Linq. (See MSDN forum thread) To solve the problem, three steps are needed: In your template’s language attribute, specify “C#v3.5” or “VBv3.5” – this step is not required for VS2010, … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)