在Visual Studio 2013库中找不到实体框架 [英] Entity Framework in Visual Studio 2013 library not found

查看:167
本文介绍了在Visual Studio 2013库中找不到实体框架的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当尝试使用Entity Framework时,在Visual Studio 2013中的Visual Studio 2013中,我收到一个非常不寻常的错误.无论是处理现有项目还是创建新项目,都没有关系.当我使用Win 8.1切换到新PC时,它开始发生.

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.

我使用向导从数据库创建一个新模型.它非常好地创建了该图.但是,我收到一个编译错误,告知库EntityFramework.dll不存在.但是,唯一的是EntityFramework.dll的路径错误(看起来像C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools\..\IDE\EntityFramework.dll).但是,该地址将为D:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE.我将在哪里更改该值?

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

推荐答案

显然,将Visual Studio重新安装到其他驱动器时,%VS120COMNTOOLS%环境变量未正确更新,并且指向原始安装VS的驱动器上的文件夹.生成DDL SQL的模板正在使用%VS120COMNTOOLS%环境变量来查找生成代码所需的程序集.由于变量指向的文件夹不再包含必需的文件,因此T4模板转换失败.

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.

故障排除:

  • 打开VS2013的开发人员命令提示符
  • 手动将变量设置为指向正确的位置(例如

  • 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\")

(请注意,如果按照上述步骤设置变量,则该变量仅适用于从此命令提示符启动的VS实例.)

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

如果上述工作进入了计算机属性(例如,在Win 8/Win 8.1中,在搜索窗口中键入"This PC"),请右键单击该图标并选择属性",然后转到高级"选项卡,然后单击环境变量"按钮,然后在系统变量"窗口中找到VS120COMNTOOLS变量,双击(或单击编辑"按钮)并修复该变量,使其指向正确的文件夹.

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.

别忘了在Tools ...之后的最后一个反斜杠... C:\ Program Files(x86)\ Microsoft Visual Studio 12.0 \ Common7 \ Tools< ----将不起作用,但是... C:\ Program文件(x86)\ Microsoft Visual Studio 12.0 \ Common7 \ Tools \< ---将起作用

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

这篇关于在Visual Studio 2013库中找不到实体框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆