【问题标题】:Could not load type 'System.Data.Entity.DbSetExtensions' from assembly 'EntityFramework无法从程序集“EntityFramework”加载类型“System.Data.Entity.DbSetExtensions”
【发布时间】:2013-08-23 07:05:24
【问题描述】:

从 entityframework 6.0.0-beta1 更新到 6.0.0-rc1,登录到我的 MVC5 应用程序时出现以下错误

 {"Could not load type 'System.Data.Entity.DbSetExtensions' from assembly 'EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.":"System.Data.Entity.DbSetExtensions"}
    [System.TypeLoadException]: {"Could not load type 'System.Data.Entity.DbSetExtensions' from assembly 'EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.":"System.Data.Entity.DbSetExtensions"}
    Data: {System.Collections.ListDictionaryInternal}
    HelpLink: null
    HResult: -2146233054
    InnerException: null
    Message: "Could not load type 'System.Data.Entity.DbSetExtensions' from assembly 'EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'."
    Source: "Microsoft.AspNet.Identity.EntityFramework"
    StackTrace: "   at Microsoft.AspNet.Identity.EntityFramework.Store`1.GetByID(Object id)\r\n   at Microsoft.AspNet.Identity.EntityFramework.UserSecretStore`1.<Find>d__c.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at Microsoft.AspNet.Identity.EntityFramework.UserSecretStore`1.<Validate>d__8.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at Microsoft.AspNet.Identity.EntityFramework.IdentityStoreManager.<ValidateLocalLogin>d__20.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.
CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at Microsoft.AspNet.Identity.EntityFramework.IdentityAuthenticationManager.<CheckPasswordAndSignIn>d__22.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()\r\n   at BASRaT5.Controllers.AccountController.<Login>d__2.MoveNext() in c:\\dev\\BASRAT\\BASRaT5\\BASRaT5\\Controllers\\AccountController.cs:line 53\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(
Task task)\r\n   at lambda_method(Closure , Task )\r\n   at System.Threading.Tasks.TaskHelpersExtensions.ThrowIfFaulted(Task task)\r\n   at System.Web.Mvc.Async.TaskAsyncActionDescriptor.EndExecute(IAsyncResult asyncResult)\r\n   at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass34.<BeginInvokeAsynchronousActionMethod>b__33(IAsyncResult asyncResult)\r\n   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`1.CallEndDelegate(IAsyncResult asyncResult)\r\n   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase`1.End()\r\n   at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult)\r\n   at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3c()\r\n   at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass45.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3e()\r\n   at System.Web.Mvc.Async.AsyncControllerAct
ionInvoker.<>c__DisplayClass30.<BeginInvokeActionMethodWithFilters>b__2f(IAsyncResult asyncResult)\r\n   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`1.CallEndDelegate(IAsyncResult asyncResult)\r\n   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase`1.End()\r\n   at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult)\r\n   at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass1e.<>c__DisplayClass28.<BeginInvokeAction>b__19()\r\n   at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass1e.<BeginInvokeAction>b__1b(IAsyncResult asyncResult)"
    TargetSite: {System.Threading.Tasks.Task`1[TEntity] GetByID(System.Object)}

我的csproj有以下参考

<Reference Include="System.Data" />
<Reference Include="System.Data.Entity.Design" />
<Reference Include="System.Data.DataSetExtensions" />

web.config

 <system.web>
    <compilation debug="true" targetFramework="4.5">
      <assemblies>
        <add assembly="System.Data.Entity.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
      </assemblies>
   </compilation
 </system.web>

这以前有效,我需要新版本的 System.Data.Entity.Design dll 吗?或更改 web.config 中的程序集版本?

编辑: Sounds like Identity Framework guys need to release a updated dll to match?

【问题讨论】:

    标签: entity-framework entity-framework-6 asp.net-mvc-5 asp.net-identity


    【解决方案1】:

    修复此问题并支持 EF6 RC 的 ASP.NET 标识更新将很快推出。

    更新:新版本是available in NuGet

    【讨论】:

    • 刚刚更新了新的包,现在出现很多错误找不到 IdentityStoreManager,找不到 IdentityStoreContext 等等。是否有一些命名空间被重命名或移动了?
    • 版本之间发生了很多变化 - 更多信息在这里 - stackoverflow.com/questions/17441157/…
    【解决方案2】:

    命名空间和移动类型发生了一些变化。我已经从 Beta1 更新了样本 - RC1 https://github.com/rustd/AspnetIdentitySample 您可以查看以下提交以获取所需更改的列表。我很快会在项目中添加一些文档https://github.com/rustd/AspnetIdentitySample/commit/b09479a9e5c2d4ff16c459ce0e4105c5ac5302f4

    【讨论】:

    • 嗨@pranav rastogi,感谢更新代码。我在上一个项目中遇到了问题,试图让它与我现有的结构一起工作。一些文档将不胜感激。顺便说一句,当我替换项目中的代码时,它会创建以 AspNet 为前缀的表,而示例项目则不是
    【解决方案3】:

    将 EntityFramework dll 版本 6 添加到我的 MVC4 项目时出现此错误。将 EntityFramework dll 降级到版本 5 解决了我的问题!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-01-02
      • 1970-01-01
      • 1970-01-01
      • 2012-05-05
      • 2010-09-19
      • 2017-11-26
      • 2020-11-26
      • 1970-01-01
      相关资源
      最近更新 更多