Entity框架代码首先迁移抛出错误 [英] Entity Framework code first migrations throwing error

查看:437
本文介绍了Entity框架代码首先迁移抛出错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经搜索了SO,google,耶稣,一切,不能算出这一个。以下是我在执行此错误之前所做的操作:

I have scoured SO, google, Jesus, everything and cannot figure this one out. Here is what I did before I got this error:


  1. 安装EF(预发布版本,6或许,I dunno) >
  2. 决定不再需要,因此已卸载并重新安装稳定版本(5)

  3. 通过SSMS截断了我的数据库

这里是错误:

Exception calling "CreateInstanceFrom" with "8" argument(s): "Could not load file or      
assembly 'EntityFramework, Version=5.0.0.0, Culture=neutral, PublicK
eyToken=b77a5c561934e089' or one of its dependencies. The located assembly's manifest   
definition does not match the assembly reference. (Exception from H
RESULT: 0x80131040)"
At C:\Projects\BCATracker.Web\packages\EntityFramework.6.0.0- 
alpha2\tools\EntityFramework.psm1:425 char:31
+     $domain.CreateInstanceFrom <<<< (
+ CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : DotNetMethodTargetInvocation


$ b b

这是我试过的:

Here is what I have tried:

从bin目录中删除所有内容,重建fail
从nuget中删除EF, package目录,readd ef in nuget。失败。
打孔墙失败

Delete everthing from the bin directory, rebuild. Fail remove EF from nuget, delete the file in the packages directory, readd ef in nuget. fail. Punch wall. Fail

请帮助!

查看proj文件我看到:

looking at the proj file I see this:

<Reference Include="EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
  <SpecificVersion>False</SpecificVersion>
  <HintPath>..\packages\EntityFramework.5.0.0\lib\net40\EntityFramework.dll</HintPath>
</Reference>

原因?

推荐答案

我想出了问题EntityFramework.dll需要在GAC为Visual Studio使用它从包管理器。

I figured out the problem. EntityFramework.dll needed to be in the GAC for Visual Studio to use it from the package manager.


  1. 启动Visual Studio命令提示符(确保以管理员身份启动Visual Studio)


  2. 输入:gacutil / i EntityFramework.dll

注意:此时重新启动计算机可能是明智之举。

Note: It may be wise to restart the computer entirely at this point.

我不知道为什么Visual Studio停止看到DLL,但这让我遇到这个问题。

I'm not sure why Visual Studio stopped seeing the DLL, but this got me past this problem.

这篇关于Entity框架代码首先迁移抛出错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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