简体   繁体   English

无法加载文件或程序集“EntityFramework.SqlServer,Version=6.0.0.0,Culture=neutral,PublicKeyToken=b77a5c561934e089”

[英]Could not load file or assembly 'EntityFramework.SqlServer, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'

I am using ASP.NET 5 and Entity Framework 6 (precisely 6.1.3), following this link .我正在使用 ASP.NET 5 和 Entity Framework 6(准确地说是 6.1.3),点击此链接 Tried every different solution like尝试了各种不同的解决方案,例如

  1. Scrapping of Version in appconfig在 appconfig 中废弃版本
  2. Adding <dependentAssembly>添加<dependentAssembly>
  3. Reinstalling EntityFramework 6 again using Update-Package -reinstall EntityFramework使用Update-Package -reinstall EntityFramework再次重新安装 EntityFramework 6
  4. Check EntityFramwork.SqlServer检查 EntityFramwork.SqlServer
  5. Cleared %temp% and did clean build along with standalone rebuild清除 %temp% 并进行干净构建以及独立重建

I get error here我在这里得到错误

[DbConfigurationType(typeof(CodeConfig))]    
public class MyContext : DbContext
{
public MyContext()
        : base("DefaultConnection") <-- error here
    {
    }
 }

But still couldn't resolve this error, any helpful links would be appreciated但仍然无法解决此错误,任何有用的链接将不胜感激

Could not load file or assembly 'EntityFramework.SqlServer, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies.无法加载文件或程序集“EntityFramework.SqlServer,Version=6.0.0.0,Culture=neutral,PublicKeyToken=b77a5c561934e089”或其依赖项之一。 The system cannot find the file specified.":"EntityFramework.SqlServer, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"系统找不到指定的文件。":"EntityFramework.SqlServer, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"

Stack Trace堆栈跟踪

at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
   at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
   at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
   at System.Activator.CreateInstance(Type type, Boolean nonPublic)
   at System.Data.Entity.Utilities.TypeExtensions.CreateInstance[T](Type type, Func`2 exceptionFactory)
   at System.Data.Entity.Utilities.TypeExtensions.CreateInstance[T](Type type, Func`3 typeMessageFactory, Func`2 exceptionFactory)
   at System.Data.Entity.Infrastructure.DependencyResolution.DbConfigurationManager.<.ctor>b__1()
   at System.Lazy`1.CreateValue()
   at System.Lazy`1.LazyInitValue()
   at System.Lazy`1.get_Value()
   at System.Data.Entity.Infrastructure.DependencyResolution.DbConfigurationManager.GetConfiguration()
   at System.Data.Entity.Infrastructure.DependencyResolution.InternalConfiguration.get_Instance()
   at System.Data.Entity.DbConfiguration.get_DependencyResolver()
   at System.Data.Entity.DbContext.InitializeLazyInternalContext(IInternalConnection internalConnection, DbCompiledModel model)
   at System.Data.Entity.DbContext..ctor(String nameOrConnectionString)
   at myproject.data.myprojectContext..ctor() in D:\Projects\Personal\myproject\myproject.data\myprojectContext.cs:line 12
   at myproject.data.Infrastructure.DatabaseFactory.Get() in D:\Projects\Personal\myproject\myproject.data\Infrastructure\DatabaseFactory.cs:line 9
   at myproject.data.Repository`1.get_DataContext() in D:\Projects\Personal\myproject\myproject.data\Repository.cs:line 28
   at myproject.data.Repository`1..ctor(IDatabaseFactory databaseFactory) in D:\Projects\Personal\myproject\myproject.data\Repository.cs:line 21
   at myproject.data.Repository.ProfileRepository..ctor(IDatabaseFactory databaseFactory) in D:\Projects\Personal\myproject\myproject.data\Repository\ProfileRepository.cs:line 9

Web.Config Web.配置

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework.SqlServer, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
  </configSections>
  <connectionStrings>
    <add name="DefaultConnection" providerName="System.Data.SqlClient" connectionString="...." />
  </connectionStrings>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
      <parameters>
        <parameter value="mssqllocaldb" />
      </parameters>
    </defaultConnectionFactory>
    <providers>
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
    </providers>
  </entityFramework>
</configuration>

First check which version EF you are using. 首先检查您使用的是哪个版本的EF。 Check the your version. 检查您的版本。 If you want to upgrade your version you can manage EF upgrade from NuGet. 如果要升级版本,则可以从NuGet管理EF升级。

Go to your Project solution - > 'Manage NuGet packet for Solution', click 'Manage' on 'Entity Framework'. 转到您的项目解决方案->“管理解决方案的NuGet数据包”,在“实体框架”上单击“管理”。

Now, Check your app.config . 现在,检查您的app.config。 Maybe here wrong version number. 也许这里的版本号错误。 The name="entityFramework" should have the correct version number. 名称=“ entityFramework”应该具有正确的版本号。

Other then this, you should try installing the nuget package for EntityFramework.SqlServer by using following command in package manager console. 除此之外,您应该尝试使用程序包管理器控制台中的以下命令为EntityFramework.SqlServer安装nuget程序包。

Install-Package EntityFramework.SqlServer -Version 7.0.0-beta6 -Pre 安装包EntityFramework.SqlServer-版本7.0.0-beta6 -Pre

The parameter of base (DbContext constructor) can be a nameOrConnectionString . base 的参数(DbContext 构造函数)可以是nameOrConnectionString See DbContext(string) .请参阅DbContext(string) So you should add name= to the parameter string.因此,您应该将name=添加到参数字符串中。

[DbConfigurationType(typeof(CodeConfig))]    
public class MyContext : DbContext
{
    public MyContext()
        : base("name=DefaultConnection")
    {
    }
}

See also this example: Derived context另请参阅此示例: 派生上下文

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法加载文件或程序集&#39;EntityFramework,Version = 6.0.0.0,Culture = neutral,PublicKeyToken = b77a5c561934e089&#39; - Could not load file or assembly 'EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' 无法加载文件或程序集“系统,版本=4.0.0.0,文化=中性,PublicKeyToken=b77a5c561934e089”或其依赖项之一 - Could not load file or assembly 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies FileNotFoundException-无法加载文件或程序集&#39;System,Version = 4.0.0.0,Culture = neutral,PublicKeyToken = b77a5c561934e089&#39; - FileNotFoundException - Could not load file or assembly 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' 无法加载文件或程序集“System.IdentityModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089”或其依赖项之一 - Could not load file or assembly 'System.IdentityModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies 无法加载文件或程序集&#39;System.Data.Linq,Version = 4.0.0.0,Culture = neutral,PublicKeyToken = b77a5c561934e089&#39;或其依赖项之一 - Could not load file or assembly 'System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies 如何解决无法从程序集 &#39;mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089&#39; 加载类型 &#39;System.ValueTuple`3&#39;? - How to resolve Could not load type 'System.ValueTuple`3' from assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'? 来自程序集“mscorlib,版本=4.0.0.0,文化=中性,PublicKeyToken=b77a5c561934e089”的“System.Security.Principal.WindowsImpersonationContext” - 'System.Security.Principal.WindowsImpersonationContext' from assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' 应该引用模块&#39;System.Data.Linq&#39;Version = 4.0.0.0,Culture = neutral,Publickeytoken = b77a5c561934e089&#39; - Module 'System.Data.Linq' Version=4.0.0.0, Culture=neutral, Publickeytoken=b77a5c561934e089' should be referenced &#39;System.Security.Permissions.SecurityPermission,mscorlib,版本 = 4.0.0.0,文化 = 中性,PublicKeyToken = b77a5c561934e089&#39; 失败 - 'System.Security.Permissions.SecurityPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed 程序集“System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089”中的类型“System.Data.DataRow”未标记为可序列化 - Type 'System.Data.DataRow' in Assembly 'System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' is not marked as serializable
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM