【发布时间】:2016-03-19 22:01:44
【问题描述】:
我已经为实体框架构建了一个 DbContext 类,每当我尝试使用 EF powertools 例如查看实体数据模型(只读)时,我都会收到以下错误:
========== 构建:0 成功,0 失败,2 最新,0 跳过 ========== System.Reflection.TargetInvocationException:调用的目标已引发异常。 ---> System.Data.Entity.Core.ProviderIncompatibleException:从数据库获取提供者信息时出错。这可能是由 Entity Framework 使用不正确的连接字符串引起的。检查内部异常以获取详细信息并确保连接字符串正确。 ---> System.Data.Entity.Core.ProviderIncompatibleException:提供者没有返回 ProviderManifestToken 字符串。 ---> System.Data.SqlClient.SqlException:建立与 SQL Server 的连接时发生与网络相关或特定于实例的错误。服务器未找到或无法访问。验证实例名称是否正确以及 SQL Server 是否配置为允许远程连接。 (提供者:SQL 网络接口,错误:50 - 发生本地数据库运行时错误。指定的 LocalDB 实例不存在。 ) 在 System.Data.SqlClient.SqlInternalConnection.OnError(SqlException 异常,布尔 breakConnection,Action`1 wrapCloseInAction) 在 System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj,布尔调用者HasConnectionLock,布尔异步关闭) 在 System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo、SqlInternalConnectionTds connHandler、布尔 ignoreSniOpenTimeout、Int64 timerExpire、布尔加密、布尔 trustServerCert、布尔集成安全、布尔 withFailover、SqlAuthenticationMethod authType) 在 System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo,字符串 newPassword,SecureString newSecurePassword,布尔型 ignoreSniOpenTimeout,TimeoutTimer 超时,布尔型 withFailover) 在 System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo,字符串 newPassword,SecureString newSecurePassword,布尔重定向用户实例,SqlConnectionString connectionOptions,SqlCredential 凭据,TimeoutTimer 超时) 在 System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(TimeoutTimer 超时,SqlConnectionString 连接选项,SqlCredential 凭据,字符串 newPassword,SecureString newSecurePassword,布尔重定向用户实例) 在 System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity 标识、SqlConnectionString connectionOptions、SqlCredential 凭据、对象 providerInfo、String newPassword、SecureString newSecurePassword、Boolean redirectedUserInstance、SqlConnectionString userConnectionOptions、SessionData reconnectSessionData、DbConnectionPool 池、字符串 accessToken) 在 System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions 选项,DbConnectionPoolKey poolKey,对象 poolGroupProviderInfo,DbConnectionPool 池,DbConnection owningConnection,DbConnectionOptions userOptions) 在 System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool 池,DbConnection owningObject,DbConnectionOptions 选项,DbConnectionPoolKey poolKey,DbConnectionOptions 用户选项) 在 System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject,DbConnectionOptions userOptions,DbConnectionInternal oldConnection) 在 System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject,DbConnectionOptions userOptions,DbConnectionInternal oldConnection) 在 System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject,UInt32 waitForMultipleObjectsTimeout,布尔allowCreate,布尔onlyOneCheckConnection,DbConnectionOptions userOptions,DbConnectionInternal& 连接) 在 System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject,TaskCompletionSource`1 重试,DbConnectionOptions userOptions,DbConnectionInternal& 连接) 在 System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection,TaskCompletionSource`1 重试,DbConnectionOptions userOptions,DbConnectionInternal oldConnection,DbConnectionInternal& 连接) 在 System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection,DbConnectionFactory connectionFactory,TaskCompletionSource`1 重试,DbConnectionOptions userOptions) 在 System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection,DbConnectionFactory connectionFactory,TaskCompletionSource`1 重试,DbConnectionOptions userOptions) 在 System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource`1 重试) 在 System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 重试) 在 System.Data.SqlClient.SqlConnection.Open() 在 System.Data.Entity.SqlServer.SqlProviderServices.c__DisplayClass2f.b__2d() 在 System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.c__DisplayClass1.b__0() 在 System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute[TResult](Func`1 操作) 在 System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute(操作操作) 在 System.Data.Entity.SqlServer.SqlProviderServices.UsingConnection(DbConnection sqlConnection,Action`1 行为) 在 System.Data.Entity.SqlServer.SqlProviderServices.UsingMasterConnection(DbConnection sqlConnection,Action`1 行为) 在 System.Data.Entity.SqlServer.SqlProviderServices.GetDbProviderManifestToken(DbConnection 连接) 在 System.Data.Entity.Core.Common.DbProviderServices.GetProviderManifestToken(DbConnection 连接) --- 内部异常堆栈跟踪结束 --- 在 System.Data.Entity.Core.Common.DbProviderServices.GetProviderManifestToken(DbConnection 连接) 在 System.Data.Entity.Utilities.DbProviderServicesExtensions.GetProviderManifestTokenChecked(DbProviderServices providerServices,DbConnection 连接) --- 内部异常堆栈跟踪结束 --- 在 System.Data.Entity.Utilities.DbProviderServicesExtensions.GetProviderManifestTokenChecked(DbProviderServices providerServices,DbConnection 连接) 在 System.Data.Entity.Infrastructure.DefaultManifestTokenResolver.c__DisplayClass1.b__0(Tuple`3 k) 在 System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory) 在 System.Data.Entity.Infrastructure.DefaultManifestTokenResolver.ResolveManifestToken(DbConnection 连接) 在 System.Data.Entity.Utilities.DbConnectionExtensions.GetProviderInfo(DbConnection 连接,DbProviderManifest 和 providerManifest) 在 System.Data.Entity.DbModelBuilder.Build(DbConnection providerConnection) 在 System.Data.Entity.Internal.LazyInternalContext.CreateModel(LazyInternalContext internalContext) 在 System.Data.Entity.Internal.RetryLazy`2.GetValue(TInput 输入) 在 System.Data.Entity.Internal.LazyInternalContext.InitializeContext() 在 System.Data.Entity.Internal.LazyInternalContext.get_CodeFirstModel() 在 System.Data.Entity.Infrastructure.EdmxWriter.WriteEdmx(DbContext 上下文,XmlWriter 编写器) --- 内部异常堆栈跟踪结束 --- 在 System.RuntimeMethodHandle.InvokeMethod(对象目标,对象 [] 参数,签名 sig,布尔构造函数) 在 System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(对象 obj,对象 [] 参数,对象 [] 参数) 在 System.Reflection.RuntimeMethodInfo.Invoke(Object obj,BindingFlags invokeAttr,Binder binder,Object[] 参数,CultureInfo 文化) 在 System.RuntimeType.InvokeMember(字符串名称、BindingFlags bindingFlags、Binder binder、Object 目标、Object[] providedArgs、ParameterModifier[] 修饰符、CultureInfo 文化、String[] namedParams) 在 Microsoft.DbContextPackage.Handlers.ViewContextHandler.ViewContext(MenuCommand menuCommand,对象上下文,类型 systemContextType)关于如何解决此问题的任何想法?
【问题讨论】:
标签: c# .net sql-server entity-framework