我在尝试进入ASP.NET项目的管理员区域时遇到此问题。
尝试导航到某个区域(example)
时,才会出现此错误出现的错误是:
“建立与SQL Server的连接时发生与网络相关或特定于实例的错误。未找到服务器或无法访问服务器。验证实例名称是否正确以及SQL Server是否配置为允许远程连接。 (提供程序:SQL网络接口,错误:26 - 查找指定的服务器/实例时出错)“
堆栈追踪:
[SqlException(0x80131904):建立与SQL Server的连接时发生与网络相关或特定于实例的错误。服务器未找到或无法访问。验证实例名称是否正确,以及SQL Server是否配置为允许远程连接。 (提供程序:SQL网络接口,错误:26 - 找到指定的服务器/实例时出错)]
System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity标识,SqlConnectionString connectionOptions,SqlCredential凭证,Object providerInfo,String newPassword,SecureString newSecurePassword,Boolean redirectedUserInstance,SqlConnectionString userConnectionOptions,SessionData reconnectSessionData,DbConnectionPool pool,String accessToken,Boolean applyTransientFaultHandling)+821
System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions选项,DbConnectionPoolKey poolKey,Object poolGroupProviderInfo,DbConnectionPool池,DbConnection owningConnection,DbConnectionOptions userOptions)+5771923
System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection,DbConnectionPoolGroup poolGroup,DbConnectionOptions userOptions)+38
System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection,TaskCompletionSource 1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection) +507
System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource
1 retry,DbConnectionOptions userOptions)+154
System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection,DbConnectionFactory connectionFactory,TaskCompletionSource 1 retry, DbConnectionOptions userOptions) +21
System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource
1重试)+90
System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)+217
System.Data.SqlClient.SqlConnection.Open()+96
System.Web.Management.SqlServices.GetSqlConnection(String server,String user,String password,Boolean trusted,String connectionString)+75
[HttpException(0x80004005):无法连接到SQL Server数据库。] System.Web.Management.SqlServices.GetSqlConnection(String server,String user,String password,Boolean trusted,String connectionString)+125 System.Web.Management.SqlServices.SetupApplicationServices(String server,String user,String password,Boolean trusted,String connectionString,String database,String dbFileName,SqlFeatures features,Boolean install)+89 System.Web.Management.SqlServices.Install(String database,String dbFileName,String connectionString)+29 System.Web.DataAccess.SqlConnectionHelper.CreateMdfFile(String fullFileName,String dataDir,String connectionString)+386
记录: 我的数据库和托管目前托管在Azure
中修改
这是我唯一的连接字符串:
connectionString="Data Source=tcp:wineux.database.windows.net,1433;Initial Catalog=wineuxproduction;User ID=*****;Password=*****;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;"
我目前正在使用微软的Owin服务。这是我在db上下文创建时的初始配置:
public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
{
public ApplicationDbContext()
: base("EfDatabase", throwIfV1Schema: false)
{
}
public static ApplicationDbContext Create()
{
return new ApplicationDbContext();
}
}
编辑2
我设法将错误更改为this
具体错误是:
无法找到存储过程'dbo.aspnet_CheckSchemaVersion'。
同样,这只在访问我的管理员区域时发生。