8

I get a rather unusual error in Visual Studio 2013 in Visual Basic when trying to work with Entity Framework. This doesn't matter whether I work with an existing project or create a new one. It started to happen when I changed to a new PC with Win 8.1.

I create a new model using the wizard from a database. It creates the diagram very nicely. However, I get an compilation error telling the library EntityFramework.dll doesn't exist. However, the only thing is that the path to EntityFramework.dll is wrong (Looks like: C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools\..\IDE\EntityFramework.dll). The address, however, would be D:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE. Where would I change that value?

Ueli

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
orca
  • 103
  • 1
  • 1
  • 7
  • Seems similar to: http://stackoverflow.com/questions/19791278/error-when-generating-database-from-model-in-visual-studio-2013/19808042#comment29470966_19808042. Can you elaborate more on your setup? The error comes from EF tooling (SsdlToSql10.tt to be exact). We have tried to repro it twice but were not able to. In general in your environment the VS120COMNTOOLS environment variable points to `C:\Program Files (x86)...` while Visual Studio is actually installed on the D drive. Any idea why the VS120COMNTOOLS points to the directory on C: ? – Pawel Nov 08 '13 at 21:17
  • Hi, seems similar the other way round. the Setup is actually that I have my OS installed on C and all program files on D. I used Visualstudio 2012 first but directly installed 2013 on the new machine. I had it firstly installed on C. Deinstalled it and made a new Installation on D. So the pointer might be left over from thw "old" installation. – orca Nov 08 '13 at 21:56
  • If you open the developer command prompt and run `set VS120COMNTOOLS` which path does it show - the correct/new one or the old one? – Pawel Nov 08 '13 at 22:26
  • Hi, you were right, it was the wrong path in the registry for vs120comntools. I changed it and it works now. Many thanks. Actually thought about this but wasn't sure. – orca Nov 09 '13 at 18:36
  • glad you got it fixed – Pawel Nov 10 '13 at 06:39

7 Answers7

25

Apparently when reinstalling Visual Studio to a different drive the %VS120COMNTOOLS% environment variable is not updated correctly and points to the folder on the drive where VS was originally installed. The template for generating DDL SQL is using the %VS120COMNTOOLS% environment variable to find assemblies it needs to generate the code. Since the variable is pointing to a folder that no longer contains the necessary files the T4 template transformation fails.

Troubleshooting:

  • Open the developer command prompt for VS2013
  • set the variable manually to point to the correct location (e.g.

    set VS120COMNTOOLS="D:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools\")

  • start VS from the command prompt by executing devenv
  • verify if things now work

(Note that if you follow the above steps to set the variable it will only work for VS instances started from this command prompt.)

If the above works go to the computer properties (e.g. in Win 8/Win 8.1 type "This PC" in the search window), right click on the icon and select "Properties", go to the "Advanced" tab and click the "Environment Variables" button, then in the "System variables" window find the VS120COMNTOOLS variable, double click (or click the "Edit" button) and fix the variable so that it points to the right folder.

Don't forget the last backslash after Tools... C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools <---- will not work, but... C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools\ <--- will work

Pawel
  • 31,342
  • 4
  • 73
  • 104
  • But when using NuGet shouldn't the EntityFramework.dll be found in (projectdir)\packages\EntityFramework.6.1.0\lib\net45\EntityFramework.dll instead? – Xenan Apr 27 '14 at 18:14
  • It is about entityframework.dll the designer is internally using for its own purposes. It's a separate copy and is independent on the package you are using in your project. – Pawel Apr 27 '14 at 21:30
  • I am facing the exact same issue, but when I followed this I found my "C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7" does not have a tools folder but "C:\Program Files (x86)\Microsoft Visual Studio 11.0" does have one and entity framework dlls. I have VS 2012 and 2013. What would you suggest in this case? One more, the above command "set" (to try set to 11.0) does not recognized in my VS command window, I am I missing something?? – Ramesh Sivaraman May 06 '14 at 03:22
  • Where is your VS (devenv.exe) installed? If you don't have the folder your VS probably is not installed on C: drive. AFAIR VS will always create a folder in C: (or system) with some files even if the main installation is on a different drive. I also does not understand what does it mean that "set" is not recognized. It's a DOS/shell command so you must be doing something wrong (e.g. make sure you are using double quotes). – Pawel May 06 '14 at 22:20
1

It might look funny but I encounter the same issue (with windows 8.1) but none of the suggested methods worked for me!! I checked my environment variables it had the correct path but when I tested it with explorer (typed %VS120COMNTOOLS% in explorer's address bar) it does not showed up!! Rather it said "windows cannot find %VS120COMNTOOLS% make sure you typed the name correctly" So what I did was I just deleted the variable and recreated it with the exact same path and after rebuild the error gone!!!

So if you guys have the same issue give it a go

Kiarash
  • 1,701
  • 2
  • 16
  • 20
1

In my case, it was a permission issue and not related to the environment variable file path as the path was correct in my case.

So what I did is added permissions to my current user on the whole visual studio installation folder and then launched Visual Studio as administrator. I re-generated my Model and it worked!

sam
  • 4,357
  • 5
  • 29
  • 34
0

I had this problem with VS2013 on Windows 8.1. I solved the problem by copying

EntityFramework.dll and Microsoft.Data.Entity.Design.dll

from C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE to C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools

The files are in both locations and now everything works fine. I had to delete my DB Entity Model and start over again to get things working. It's probably just an MS coding error making VS2013 look in the wrong place.

0

I had this problem with VS2013 on Windows Server 2012R2. Two drives (C and D). I tried repairing and uninstall-reinstall but that didn't fix anything. It was hacky but I got it to work.

First I changed the system variables to go from D to C. To do this, go to Control Panel --> System and Security --> System. On the left hand side you will see Advanced System Settings. On the bottom of the Advanced tab you see Environment Variables. I had to edit VS120COMNTOOLS to C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools. It previously was D:\Program Files\Microsoft Visual Studio 12.0\Common7\Tools.

Then I copied the EntityFramework.dll and Microsoft.Data.Entity.Design.dll from C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE to C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools\IDE. If the IDE folder doesn't exist then create one. That is what I had to do. Seems so strange but it works!

I had to delete the current edmx in my project, readd it, and restart VS. Such a wierd problem and took me quite a while to piece together multiple stackoverflow articles to get the whole problem solved.

0

The following path of %VS120COMNTOOLS% is working for me:

set VS120COMNTOOLS="D:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\"

hamming122
  • 43
  • 1
  • 6
-1

I also faced the same issue. I have my VS2012 at "D:\Program Files (x86)\".

I tried to set the common folder for VS using the following set command from VS2012 command Prompt.

set VS120COMN="D:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7"

This resolved the issue for me.