Sunday, September 15, 2013

One or more errors occurred while processing template 'Entity.tt'. Using Reverse Engineer Code First in VS 2012 Update 1

Hi,

Using VS 2012 Update 1, I was doing some changes in my database schema and when i try to reverse engineer code first my updates i was getting the following error:

One or more errors occurred while processing template 'Entity.tt'.

In the output window, VS listed that System.Xml and System.Xml.Linq exist on 2 different paths, one where the .NET framework is installed and the other one is pointing to the Siliverlight 5 DLLs in the GAC.

While it is reported as a bug in Microsoft Connect website, I was trying to remove the link to the Silverlight 5 Dlls that i'm not in need when i reverse engineer code first my EF files to apply my DB changes.

To fix this problem: 
1) Open the following directory:

C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\Extensions\Microsoft\Entity Framework Tools\Templates\Includes

2) Take a backup from EF.Utility.CS.ttinclude or the VB version based on the your project language you are using.

3) Open the notepad in an administrator mode.

4) Open the CS.ttinclude file.

5) change the following 2 lines:

<#@ assembly name="System.Xml" #>
Change it to:
<#@ assembly name="System.Xml, Version 4.0.0.0, Culture=neutral" #>

<#@ assembly name="System.Xml.Linq"#>
Change it to:
<#@ assembly name="System.Xml.Linq, Version 4.0.0.0, Culture=neutral"#>

6) Save the file.

7) Right click on the project that has the EF files and click on Reverse engineer Code First.

8) bingo! you will get your database updates with no errors.


Let me know if you have any issues with this.

Post a Comment