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

bry*_*val 8 c# asp.net asp.net-mvc entity-framework-6 asp.net5

我正在使用ASP.NET 5和Entity Framework 6(正好是6.1.3),遵循此链接.尝试过各种不同的解决方案

  1. 在appconfig中废弃版本
  2. 添加 <dependentAssembly>
  3. 使用再次重新安装EntityFramework 6 Update-Package -reinstall EntityFramework
  4. 检查EntityFramwork.SqlServer
  5. 已清除%temp%,并进行了清理构建以及独立重建

我在这里得到错误

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

但仍然无法解决此错误,任何有用的链接将不胜感激

无法加载文件或程序集'EntityFramework.SqlServer,Version = 6.0.0.0,Culture = neutral,PublicKeyToken = b77a5c561934e089'或其依赖项之一.系统找不到指定的文件.":"EntityFramework.SqlServer,Version = 6.0.0.0,Culture = neutral,PublicKeyToken = b77a5c561934e089"

堆栈跟踪

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
Run Code Online (Sandbox Code Playgroud)

Web.Config中

<?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>
Run Code Online (Sandbox Code Playgroud)

Rei*_*abh 0

首先检查您使用的是哪个版本的 EF。检查您的版本。如果您想升级版本,可以从 NuGet 管理 EF 升级。

转到您的项目解决方案 - >“管理解决方案的 NuGet 数据包”,单击“实体框架”上的“管理”。

现在,检查您的 app.config 。也许这里的版本号错误。name="entityFramework" 应具有正确的版本号。

除此之外,您应该尝试在包管理器控制台中使用以下命令安装 EntityFramework.SqlServer 的 nuget 包。

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