vb.net 找不到 Visual Studio 2013 库中的实体框架
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19867641/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Entity Framework in Visual Studio 2013 library not found
提问by orca
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.
尝试使用实体框架时,我在 Visual Basic 中的 Visual Studio 2013 中遇到了一个相当不寻常的错误。无论我是使用现有项目还是创建新项目,这都无关紧要。当我换到一台装有 Win 8.1 的新 PC 时,它开始发生。
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.dlldoesn't exist. However, the only thing is that the path to EntityFramework.dllis 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?
我使用数据库中的向导创建了一个新模型。它非常好地创建了图表。但是,我收到一个编译错误,告诉该库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。我会在哪里更改该值?
Ueli
于利
回答by Pawel
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.
显然,将 Visual Studio 重新安装到其他驱动器时,%VS120COMNTOOLS%环境变量未正确更新并指向最初安装 VS 的驱动器上的文件夹。生成 DDL SQL 的模板使用%VS120COMNTOOLS%环境变量来查找生成代码所需的程序集。由于变量指向一个不再包含必要文件的文件夹,T4 模板转换失败。
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
- 打开 VS2013 的开发者命令提示符
手动设置变量以指向正确的位置(例如
set VS120COMNTOOLS="D:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools\")- 通过执行从命令提示符启动 VS
devenv - 验证现在是否有效
(Note that if you follow the above steps to set the variable it will only work for VS instances started from this command prompt.)
(请注意,如果您按照上述步骤设置变量,它将仅适用于从此命令提示符启动的 VS 实例。)
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 VS120COMNTOOLSvariable, double click (or click the "Edit" button) and fix the variable so that it points to the right folder.
如果上述工作转到计算机属性(例如在 Win 8/Win 8.1 中,在搜索窗口中键入“This PC”),右键单击该图标并选择“属性”,转到“高级”选项卡并单击“ Environment Variables”按钮,然后在“System variables”窗口中找到该VS120COMNTOOLS变量,双击(或单击“Edit”按钮)并修复该变量,使其指向正确的文件夹。
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
不要忘记 Tools... C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools <---- 后的最后一个反斜杠 <---- 将不起作用,但是... C:\Program Files (x86) \Microsoft Visual Studio 12.0\Common7\Tools\ <--- 将工作
回答by sam
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!
所以我所做的是在整个 Visual Studio 安装文件夹中为当前用户添加权限,然后以管理员身份启动 Visual Studio。我重新生成了我的模型并且它起作用了!
回答by Kiarash
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!!!
它可能看起来很有趣,但我遇到了同样的问题(在 Windows 8.1 中),但没有一个建议的方法对我有用!!我检查了我的环境变量它有正确的路径但是当我用资源管理器测试它时(在资源管理器的地址栏中输入 %VS120COMNTOOLS%)它没有出现!!而是说“windows 找不到 %VS120COMNTOOLS% 请确保您正确输入了名称”所以我所做的是我只是删除了变量并使用完全相同的路径重新创建它,重建后错误消失了!!!
So if you guys have the same issue give it a go
所以如果你们有同样的问题,请试一试
回答by Philip Harding
I had this problem with VS2013 on Windows 8.1. I solved the problem by copying
我在 Windows 8.1 上使用 VS2013 时遇到了这个问题。我通过复制解决了这个问题
EntityFramework.dll and Microsoft.Data.Entity.Design.dll
EntityFramework.dll 和 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
从 C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE 到 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.
这些文件位于两个位置,现在一切正常。我不得不删除我的 DB 实体模型并重新开始以使事情正常工作。这可能只是导致 VS2013 出现在错误位置的 MS 编码错误。
回答by Taylor Bouman
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.
我在 Windows Server 2012R2 上使用 VS2013 时遇到了这个问题。两个驱动器(C 和 D)。我尝试修复和卸载重新安装,但这并没有解决任何问题。这是hacky,但我让它工作。
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.
首先,我将系统变量从 D 更改为 C。为此,请转到控制面板 --> 系统和安全 --> 系统。在左侧,您将看到高级系统设置。在高级选项卡的底部,您会看到环境变量。我不得不将 VS120COMNTOOLS 编辑为 C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools。它以前是 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!
然后我将 EntityFramework.dll 和 Microsoft.Data.Entity.Design.dll 从 C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE 复制到 C:\Program Files (x86)\Microsoft Visual Studio 12.0\ Common7\工具\IDE。如果 IDE 文件夹不存在,则创建一个。这就是我必须做的。看起来很奇怪,但它有效!
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.
我不得不在我的项目中删除当前的 edmx,读取它,然后重新启动 VS。这么奇怪的问题,我花了很长时间才把多篇stackoverflow文章拼凑起来,才解决了整个问题。
回答by hamming122
The following path of %VS120COMNTOOLS% is working for me:
%VS120COMNTOOLS% 的以下路径对我有用:
set VS120COMNTOOLS="D:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\"
设置 VS120COMNTOOLS="D:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\"
回答by Arun Vijayan
I also faced the same issue. I have my VS2012 at "D:\Program Files (x86)\".
我也面临同样的问题。我的 VS2012 位于“D:\Program Files (x86)\”。
I tried to set the common folder for VS using the following set command from VS2012 command Prompt.
我尝试使用以下来自 VS2012 命令提示符的 set 命令为 VS 设置公共文件夹。
set VS120COMN="D:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7"
设置 VS120COMN="D:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7"
This resolved the issue for me.
这为我解决了这个问题。

