asp.net-mvc-5 – 如何让Glimpse与EF6合作?
编辑:底部添加堆栈跟踪.
我有一个ASP.NET MVC 5项目,它通过Entity Framework 6使用SQL Server数据库. 我将Glimpse(和Glimpse.MVC5)添加到项目中,这很好. 但是,当我添加Glimpse.EF6时,我的应用程序一旦尝试访问数据库就会抛出异常.例外是: System.NotSupportedException
这是怎么回事?仅供参考,我的web.config的connectionStrings部分如下所示: <connectionStrings> <add name="DefaultConnection" connectionString="Data Source=.; Initial Catalog=foo; Integrated Security=True; MultipleActiveResultSets=True;" providerName="System.Data.SqlClient" /> </connectionStrings> …我的Application_Start方法如下所示: protected void Application_Start() { AreaRegistration.RegisterAllAreas(); GlobalConfiguration.Configure(WebApiConfig.Register); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); Database.SetInitializer(new WebApplication.Models.Storage.ApplicationDbInitializer()); } …我的上下文类看起来像这样: public class ApplicationDbContext : IdentityDbContext<ApplicationUser> { public ApplicationDbContext() : base("DefaultConnection") { } public DbSet<Foo> Foos { get; set; } } 在此先感谢任何帮助…… 堆栈跟踪: [NotSupportedException: Unable to determine the provider name for provider factory of type 'System.Data.SqlClient.SqlClientFactory'. Make sure that the ADO.NET provider is installed or registered in the application config.] System.Data.Entity.Utilities.DbProviderFactoryExtensions.GetProviderInvariantName(DbProviderFactory factory) +290 System.Data.Entity.Infrastructure.DependencyResolution.DefaultInvariantNameResolver.GetService(Type type,Object key) +248 System.Data.Entity.Infrastructure.DependencyResolution.<>c__DisplayClass1.<GetService>b__0(Tuple`2 k) +75 System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key,Func`2 valueFactory) +72 System.Data.Entity.Infrastructure.DependencyResolution.CachingDependencyResolver.GetService(Type type,Object key) +210 System.Data.Entity.Infrastructure.DependencyResolution.<>c__DisplayClass3.<GetService>b__0(IDbDependencyResolver r) +60 System.Linq.WhereSelectArrayIterator`2.MoveNext() +66 System.Linq.Enumerable.FirstOrDefault(IEnumerable`1 source,Func`2 predicate) +161 System.Data.Entity.Infrastructure.DependencyResolution.ResolverChain.GetService(Type type,Object key) +250 System.Data.Entity.Infrastructure.DependencyResolution.RootDependencyResolver.GetService(Type type,Object key) +106 System.Data.Entity.Infrastructure.DependencyResolution.<>c__DisplayClass3.<GetService>b__0(IDbDependencyResolver r) +60 System.Linq.WhereSelectArrayIterator`2.MoveNext() +66 System.Linq.Enumerable.FirstOrDefault(IEnumerable`1 source,Func`2 predicate) +94 System.Data.Entity.Infrastructure.DependencyResolution.ResolverChain.GetService(Type type,Object key) +250 System.Data.Entity.Infrastructure.DependencyResolution.CompositeResolver`2.GetService(Type type,Object key) +102 System.Data.Entity.Infrastructure.DependencyResolution.DbDependencyResolverExtensions.GetService(IDbDependencyResolver resolver,Object key) +145 System.Data.Entity.Core.Common.<>c__DisplayClass5.<GetExecutionStrategy>b__4(ExecutionStrategyKey k) +84 System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key,Func`2 valueFactory) +72 System.Data.Entity.Core.Common.DbProviderServices.GetExecutionStrategy(DbConnection connection,DbProviderFactory providerFactory) +351 System.Data.Entity.Core.Common.DbProviderServices.GetExecutionStrategy(DbConnection connection) +62 System.Data.Entity.SqlServer.SqlProviderServices.UsingConnection(DbConnection sqlConnection,Action`1 act) +319 System.Data.Entity.SqlServer.SqlProviderServices.UsingMasterConnection(DbConnection sqlConnection,Action`1 act) +335 System.Data.Entity.SqlServer.SqlProviderServices.GetDbProviderManifestToken(DbConnection connection) +399 System.Data.Entity.Core.Common.DbProviderServices.GetProviderManifestToken(DbConnection connection) +132 [ProviderIncompatibleException: The provider did not return a ProviderManifestToken string.] System.Data.Entity.Core.Common.DbProviderServices.GetProviderManifestToken(DbConnection connection) +327 Glimpse.EF.AlternateType.GlimpseDbProviderServices.GetDbProviderManifestToken(DbConnection connection) +113 System.Data.Entity.Core.Common.DbProviderServices.GetProviderManifestToken(DbConnection connection) +255 System.Data.Entity.Utilities.DbProviderServicesExtensions.GetProviderManifestTokenChecked(DbProviderServices providerServices,DbConnection connection) +67 [ProviderIncompatibleException: An error occurred accessing the database. This usually means that the connection to the database failed. Check that the connection string is correct and that the appropriate DbContext constructor is being used to specify it or find it in the application's config file. See http://go.microsoft.com/fwlink/?LinkId=386386 for information on DbContext and connections. See the inner exception for details of the failure.] System.Data.Entity.Utilities.DbProviderServicesExtensions.GetProviderManifestTokenChecked(DbProviderServices providerServices,DbConnection connection) +277 System.Data.Entity.Infrastructure.<>c__DisplayClass1.<ResolveManifestToken>b__0(Tuple`3 k) +63 System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key,Func`2 valueFactory) +72 System.Data.Entity.Infrastructure.DefaultManifestTokenResolver.ResolveManifestToken(DbConnection connection) +360 System.Data.Entity.Utilities.DbConnectionExtensions.GetProviderInfo(DbConnection connection,DbProviderManifest& providerManifest) +89 System.Data.Entity.DbModelBuilder.Build(DbConnection providerConnection) +79 System.Data.Entity.Internal.LazyInternalContext.CreateModel(LazyInternalContext internalContext) +143 System.Data.Entity.Internal.RetryLazy`2.GetValue(TInput input) +171 System.Data.Entity.Internal.LazyInternalContext.InitializeContext() +594 System.Data.Entity.Internal.InternalContext.Initialize() +31 System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType) +39 System.Data.Entity.Internal.Linq.InternalSet`1.Initialize() +138 System.Data.Entity.Internal.Linq.InternalSet`1.Include(String path) +41 System.Data.Entity.Infrastructure.DbQuery`1.Include(String path) +142 System.Data.Entity.QueryableExtensions.Include(IQueryable`1 source,String path) +205 System.Data.Entity.QueryableExtensions.Include(IQueryable`1 source,Expression`1 path) +305 Microsoft.AspNet.Identity.EntityFramework.UserStore`6.GetUserAggregateAsync(Expression`1 filter) +610 Microsoft.AspNet.Identity.EntityFramework.UserStore`6.FindByNameAsync(String userName) +1070 Microsoft.AspNet.Identity.<FindByNameAsync>d__10.MoveNext() +283 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +93 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +52 System.Runtime.CompilerServices.ConfiguredTaskAwaiter.GetResult() +24 Microsoft.AspNet.Identity.<FindAsync>d__18.MoveNext() +673 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +93 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +52 System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() +24 WebApplication.Controllers.<Login>d__2.MoveNext() in c:UsersGaryDocumentsVisual Studio 2013ProjectseByGumWebApplicationControllersAccountController.cs:49 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 Castle.Proxies.AsyncControllerActionInvokerProxy.EndInvokeActionMethod_callback(IAsyncResult asyncResult) +42 Castle.Proxies.Invocations.AsyncControllerActionInvoker_EndInvokeActionMethod.InvokeMethodOnTarget() +103 Castle.DynamicProxy.AbstractInvocation.Proceed() +117 Glimpse.Core.Extensibility.CastleInvocationToAlternateMethodContextAdapter.Proceed() +48 Glimpse.Mvc.AlternateType.EndInvokeActionMethod.NewImplementation(IAlternateMethodContext context) +152 Glimpse.Core.Extensibility.AlternateTypeToCastleInterceptorAdapter.Intercept(IInvocation invocation) +183 Castle.DynamicProxy.AbstractInvocation.Proceed() +483 Castle.Proxies.AsyncControllerActionInvokerProxy.EndInvokeActionMethod(IAsyncResult asyncResult) +203 System.Web.Mvc.Async.AsyncInvocationWithFilters.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f() +117 System.Web.Mvc.Async.<>c__DisplayClass48.<InvokeActionMethodFilterAsynchronouslyRecursive>b__41() +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) +184 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) +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) +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() +9514812 System.Web.HttpApplication.ExecuteStep(IExecutionStep step,Boolean& completedSynchronously) +155 解决方法
对于那些寻找解决方法的人:
它看起来像是一个bug within EF itself(上面提到的是173,但链接是正确的).您可以等待EF 6.1.1 / 6.2,也可以降级到EF 6.0.2,它将再次开始工作. 在包管理器控制台中,键入以下内容: Install-Package EntityFramework -Version 6.0.2 你应该好好去. 但只有EF 6.0.2是您的选择.祝好运. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
- ASP.NET C#多项目解决方案.我应该把我的全局效用函数放在哪
- asp.net – ASP .Net Textbox Textchanged事件
- asp.net-mvc-3 – ASP.NET MVC3中的“返回类型”
- asp.net-mvc – 双值绑定问题
- asp.net-mvc – 为什么Microsoft堆栈说成本高昂?
- asp.net-mvc – 为什么大多数MVC样本控制器代码都返回Actio
- asp.net-mvc – 在asp.net mvc中设置为Session的持久cookie
- asp.net – 使用web.config存储设置的替代方法(适用于复杂的
- 网易云音乐无版权音乐补全工具
- asp.net-mvc – 记录死亡的所有黄色屏幕,即使它是编译问题
- asp.net-core – MVC 6安装为Windows服务(ASP.NE
- asp.net-mvc – LINQ Distinct()
- asp.net-mvc-3 – 使用表单身份验证的MVC3中的简
- 从wsdl文件更新asp.net WebService引用?
- asp.net – 使用DependencyResolver进行MVC 3的C
- asp.net-mvc – 变化:*错误地添加到http标头响应
- ASP.NET Core的配置(1):读取配置信息
- .NET Core 3.0及ASP.NET Core 3.0 前瞻
- asp.net – 我很难很好地定位这个按钮
- asp.net-mvc – 在WCF项目中设置Web API