2016-12-08 7 views
0

WebFormsアプリケーションがエンティティフレームワークにアクセスしてデータベースを作成するのはなぜですか?コードとweb.configでEFへの参照をすべて削除しました。私はInProcセッション状態を使用しようとしています。しかし、私のセッションが期限切れになったり、アプリケーションプールがブラウザからの呼び出しをリサイクルすると、スピンが長くなり、最終的にはEFからデータベースを作成しようとする例外が発生します。ASP.NET WebFormsアプリケーションでデータベースを作成しようとしています

 

A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified) 
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.Data.SqlClient.SqlException: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified) 

Source Error: 


An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. 

Stack Trace: 



[SqlException (0x80131904): A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)] 
    System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, DbConnectionPool pool, String accessToken, Boolean applyTransientFaultHandling) +830 
    System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions) +329 
    System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions) +38 
    System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection) +682 
    System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection) +89 
    System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection) +426 
    System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection) +78 
    System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection) +191 
    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 retry) +90 
    System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry) +217 
    System.Data.SqlClient.SqlConnection.Open() +96 
    System.Data.Entity.Infrastructure.Interception.DbConnectionDispatcher.b__36(DbConnection t, DbConnectionInterceptionContext c) +10 
    System.Data.Entity.Infrastructure.Interception.InternalDispatcher`1.Dispatch(TTarget target, Action`2 operation, TInterceptionContext interceptionContext, Action`3 executing, Action`3 executed) +72 
    System.Data.Entity.Infrastructure.Interception.DbConnectionDispatcher.Open(DbConnection connection, DbInterceptionContext interceptionContext) +360 
    System.Data.Entity.SqlServer.c__DisplayClass33.b__32() +426 
    System.Data.Entity.SqlServer.c__DisplayClass1.b__0() +10 
    System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute(Func`1 operation) +189 
    System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute(Action operation) +78 
    System.Data.Entity.SqlServer.SqlProviderServices.UsingConnection(DbConnection sqlConnection, Action`1 act) +175 
    System.Data.Entity.SqlServer.SqlProviderServices.UsingMasterConnection(DbConnection sqlConnection, Action`1 act) +556 
    System.Data.Entity.SqlServer.SqlProviderServices.CreateDatabaseFromScript(Nullable`1 commandTimeout, DbConnection sqlConnection, String createDatabaseScript) +86 
    System.Data.Entity.SqlServer.SqlProviderServices.DbCreateDatabase(DbConnection connection, Nullable`1 commandTimeout, StoreItemCollection storeItemCollection) +164 
    System.Data.Entity.Core.Common.DbProviderServices.CreateDatabase(DbConnection connection, Nullable`1 commandTimeout, StoreItemCollection storeItemCollection) +76 
    System.Data.Entity.Core.Objects.ObjectContext.CreateDatabase() +134 
    System.Data.Entity.Migrations.Utilities.DatabaseCreator.Create(DbConnection connection) +119 
    System.Data.Entity.Migrations.DbMigrator.EnsureDatabaseExists(Action mustSucceedToKeepDatabase) +142 
    System.Data.Entity.Migrations.DbMigrator.Update(String targetMigration) +78 
    System.Data.Entity.Internal.DatabaseCreator.CreateDatabase(InternalContext internalContext, Func`3 createMigrator, ObjectContext objectContext) +89 
    System.Data.Entity.Internal.InternalContext.CreateDatabase(ObjectContext objectContext, DatabaseExistenceState existenceState) +116 
    System.Data.Entity.Database.Create(DatabaseExistenceState existenceState) +218 
    System.Data.Entity.CreateDatabaseIfNotExists`1.InitializeDatabase(TContext context) +151 
    System.Data.Entity.Internal.c__DisplayClassf`1.b__e() +76 
    System.Data.Entity.Internal.InternalContext.PerformInitializationAction(Action action) +60 
    System.Data.Entity.Internal.InternalContext.PerformDatabaseInitialization() +357 
    System.Data.Entity.Internal.LazyInternalContext.b__4(InternalContext c) +7 
    System.Data.Entity.Internal.RetryAction`1.PerformAction(TInput input) +110 
    System.Data.Entity.Internal.LazyInternalContext.InitializeDatabaseAction(Action`1 action) +198 
    System.Data.Entity.Internal.LazyInternalContext.InitializeDatabase() +73 
    System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType) +28 
    System.Data.Entity.Internal.Linq.InternalSet`1.Initialize() +53 
    System.Data.Entity.Internal.Linq.InternalSet`1.get_InternalContext() +15 
    System.Data.Entity.Internal.Linq.InternalSet`1.FindAsync(CancellationToken cancellationToken, Object[] keyValues) +53 
    System.Data.Entity.DbSet`1.FindAsync(CancellationToken cancellationToken, Object[] keyValues) +34 
    System.Data.Entity.DbSet`1.FindAsync(Object[] keyValues) +26 
    Microsoft.AspNet.Identity.EntityFramework.EntityStore`1.GetByIdAsync(Object id) +49 
    Microsoft.AspNet.Identity.EntityFramework.d__6c.MoveNext() +163 
    System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +92 
    System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +58 
    Microsoft.AspNet.Identity.CultureAwaiter`1.GetResult() +59 
    Microsoft.AspNet.Identity.Owin.b__1>d__4.MoveNext() +909 
    System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +92 
    System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +58 
    System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task) +11532712 
    Microsoft.Owin.Security.Cookies.d__2.MoveNext() +2151 
    System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +92 
    System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +58 
    Microsoft.Owin.Security.Infrastructure.d__0.MoveNext() +581 
    System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +92 
    System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +58 
    Microsoft.Owin.Security.Infrastructure.d__0.MoveNext() +225 
    System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +92 
    System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +58 
    Microsoft.AspNet.Identity.Owin.d__0.MoveNext() +409 
    System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +92 
    System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +58 
    Microsoft.AspNet.Identity.Owin.d__0.MoveNext() +409 
    System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +92 
    System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +58 
    Microsoft.AspNet.Identity.Owin.d__0.MoveNext() +409 
    System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +92 
    System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +58 
    Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.d__5.MoveNext() +187 
    System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +92 
    System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +58 
    Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.d__2.MoveNext() +185 
    Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.StageAsyncResult.End(IAsyncResult ar) +69 
    Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.IntegratedPipelineContext.EndFinalWork(IAsyncResult ar) +64 
    System.Web.AsyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +380 
    System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155 




Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.6.1055.0 
+1

エンティティフレームワークへの参照を持つ別のプロジェクトを参照している可能性はありますか?新しいバージョンのasp.net IDエンティティフレームワークを使用します。 packages.configのコピーを投稿できますか? –

+0

私はasp.netアイデンティティを参照しています。それは何をしようとしていますか? – dviljoen

+0

ユーザー、ロール、および使用する他のすべてのaspnet_テーブルを格納するデータベースを作成します。エンティティフレームワークを使用するのは新しいバージョンだけです。バージョン番号を調べることができます。 –

答えて

1

あなたは、エンティティフレームワークへの参照を持っている別のプロジェクトを参照している任意のチャンスを(下記参照)?新しいバージョンのasp.net IDエンティティフレームワークを使用します。

+0

ありがとうございました! – dviljoen

関連する問題