Asp.net mvc 5 ';System.ComponentModel.DataAnnotations.Schema.IndexAttribute';
我在尝试用MVC5设置Asp.Net Identity 2.1时遇到了一个问题,并且安装了entity Framework 6.1.2库。但是,当我运行应用程序并尝试使用它来注册一个用户时,我会遇到以下错误:Asp.net mvc 5 ';System.ComponentModel.DataAnnotations.Schema.IndexAttribute';,asp.net-mvc-5,asp.net-identity,Asp.net Mvc 5,Asp.net Identity,我在尝试用MVC5设置Asp.Net Identity 2.1时遇到了一个问题,并且安装了entity Framework 6.1.2库。但是,当我运行应用程序并尝试使用它来注册一个用户时,我会遇到以下错误: Could not load type 'System.ComponentModel.DataAnnotations.Schema.IndexAttribute' from assembly 'EntityFramework, Version=6.0.0.0, Culture=neutra
Could not load type 'System.ComponentModel.DataAnnotations.Schema.IndexAttribute' from assembly 'EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
[TypeLoadException: Could not load type 'System.ComponentModel.DataAnnotations.Schema.IndexAttribute' from assembly 'EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.] Microsoft.AspNet.Identity.EntityFramework.IdentityDbContext`6.OnModelCreating(DbModelBuilder modelBuilder) +0 System.Data.Entity.Internal.LazyInternalContext.CreateModelBuilder() +375 System.Data.Entity.Internal.LazyInternalContext.CreateModel(LazyInternalContext internalContext) +15 System.Data.Entity.Internal.RetryLazy`2.GetValue(TInput input) +123 System.Data.Entity.Internal.LazyInternalContext.InitializeContext() +602 System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType) +18 System.Data.Entity.Internal.Linq.InternalSet`1.Initialize() +53 System.Data.Entity.Internal.Linq.InternalSet`1.Include(String path) +18 System.Data.Entity.Infrastructure.DbQuery`1.Include(String path) +66 System.Data.Entity.QueryableExtensions.Include(IQueryable`1 source, String path) +130 System.Data.Entity.QueryableExtensions.Include(IQueryable`1 source, Expression`1 path) +181 Microsoft.AspNet.Identity.EntityFramework.UserStore`6.GetUserAggregateAsync(Expression`1 filter) +609 Microsoft.AspNet.Identity.EntityFramework.UserStore`6.FindByNameAsync(String userName) +1072 Microsoft.AspNet.Identity.UserManager`2.FindByNameAsync(String userName) +178 Microsoft.AspNet.Identity.Owin.<PasswordSignInAsync>d__29.MoveNext() +217 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +93 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +52 System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() +24 TestID.Controllers.<Login>d__2.MoveNext() in f:\CodeSamples\IDClaims\TestID\TestID\Controllers\AccountController.cs:78 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +93 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +52 System.Runtime.CompilerServices.TaskAwaiter.GetResult() +21 System.Threading.Tasks.TaskHelpersExtensions.ThrowIfFaulted(Task task) +61 System.Web.Mvc.Async.TaskAsyncActionDescriptor.EndExecute(IAsyncResult asyncResult) +114 System.Web.Mvc.Async.<>c__DisplayClass37.<BeginInvokeAsynchronousActionMethod>b__36(IAsyncResult asyncResult) +66 System.Web.Mvc.Async.WrappedAsyncResult`1.CallEndDelegate(IAsyncResult asyncResult) +47 System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +136 System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +102 System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult) +49 System.Web.Mvc.Async.AsyncInvocationWithFilters.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3d() +117 System.Web.Mvc.Async.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f() +323 System.Web.Mvc.Async.<>c__DisplayClass33.<BeginInvokeActionMethodWithFilters>b__32(IAsyncResult asyncResult) +44 System.Web.Mvc.Async.WrappedAsyncResult`1.CallEndDelegate(IAsyncResult asyncResult) +47 System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +136 System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +102 System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult) +50 System.Web.Mvc.Async.<>c__DisplayClass2b.<BeginInvokeAction>b__1c() +72 System.Web.Mvc.Async.<>c__DisplayClass21.<BeginInvokeAction>b__1e(IAsyncResult asyncResult) +185 System.Web.Mvc.Async.WrappedAsyncResult`1.CallEndDelegate(IAsyncResult asyncResult) +42 System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +133 System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +56 System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +40 System.Web.Mvc.Controller.<BeginExecuteCore>b__1d(IAsyncResult asyncResult, ExecuteCoreState innerState) +34 System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +70 System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +139 System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +59 System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +40 System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +44 System.Web.Mvc.Controller.<BeginExecute>b__15(IAsyncResult asyncResult, Controller controller) +39 System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +62 System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +139 System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +59 System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +40 System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +39 System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult) +39 System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__5(IAsyncResult asyncResult, ProcessRequestState innerState) +39 System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +70 System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +139 System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +59 System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +40 System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +40 System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +38 System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +9657896 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155
但是仍然会遇到同样的问题,我使用ASP.Net Identity 2.1.0和Entity Framework 6.1.2,package.config指向正确的版本,引用指向正确的包目录,项目引用指向Entity 6.1.2的正确引用目录。嗯
即使进入对象浏览器,我也可以在System.ComponentModel.Data.Annotation.Schema中看到IndexAttribute
方法。
在我看来,有一件事确实很奇怪,那就是在.NET Reflector对象浏览器中,实体框架程序集看起来像6.0.0.0,但不知道为什么所有引用都是6.1.2
如有任何帮助,将不胜感激O) 不确定这是否解决了我的问题,或者是否仍然存在问题,我从CodePlex下载了示例文件;并在本地打开项目,还原站点的包,然后在本地运行应用程序,因为这使用的是Entity 6.1.2,identity有效。然后,我再次运行了一个新的测试应用程序,首先安装了EntityFramework6.1.2,然后测试了我的应用程序,它似乎正常工作。我真的无法回答为什么这一切突然开始起作用,有什么想法吗?
C:\Users\[username]\AppData\Local\Temp\Temporary ASP.NET Files\ %SystemRoot%\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\ %SystemRoot%\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\ %SystemRoot%\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\ %SystemRoot%\Microsoft.NET\Framework64\v2.0.50727\Temporary ASP.NET Files\