Metadata file not found – Data.Entity.Model

Based on C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\Extensions\Microsoft\Entity Framework Tools\Templates\Includes\EF6.Utility.CS.ttinclude , the code generator is looking for the missing DLLs in the following locations: <#@ assembly name=”%VS120COMNTOOLS%..\IDE\EntityFramework.dll” #> <#@ assembly name=”%VS120COMNTOOLS%..\IDE\Microsoft.Data.Entity.Design.dll” #> I discovered that the environment variable %VS120COMNTOOLS% is not compatible with the correct installation path of visual studio, so I changed it from … Read more

T4 template to Generate Enums

I have written one for my needs that converts a lookup table of your choice to an enum: Put this code inside an EnumGenerator.ttinclude file: <#@ template debug=”true” hostSpecific=”true” #> <#@ output extension=”.generated.cs” #> <#@ Assembly Name=”System.Data” #> <#@ import namespace=”System.Data” #> <#@ import namespace=”System.Data.SqlClient” #> <#@ import namespace=”System.IO” #> <#@ import namespace=”System.Text.RegularExpressions” #> <# … Read more

T4 without Visual Studio?

I wrote a cleanly reverse-engineered implementation of a T4 engine for the MonoDevelop IDE. It’s open-source, licensed under the permissive MIT/X11 license, so you are free to embed the engine in your app or redistribute it. There’s also an implementation of the TextTransform.exe command-line tool available as a dotnet global tool, and some APIs in … 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