0

Windows-server 2012にEnitity Frameworkを使用してasp.netアプリケーションをデプロイしようとしています。 Visual Studioでアプリケーションを実行すると、うまく動作し、AppDbContextのコンストラクタの文字列によってEntity-Framework Code Firstを使用してlocalDBが作成されます。Windowsサーバ2012にasp.netアプリケーションをデプロイする際にデータベースエラーが発生しました

解決策をC:/ inetputb/wwwrootにコピーし、インターネットインフォメーションサービスマネージャを使用して新しいWebサイトを作成しました。そこで私のソリューションのプレゼンテーションレイヤーを物理パスとして設定しました。

私がページを閲覧起動すると、私はこのエラーを取得:

 Server Error in '/' Application. 
-------------------------------------------------------------------------------- 


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: 50 - Local 
Database Runtime error occurred. Cannot create an automatic instance. See the 
Windows Application event log for error details. 
) 
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: 50 - Local Database Runtime error 
occurred. Cannot create an automatic instance. See the Windows Application 
event log for error details. 
) 

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: 50 - Local Database Runtime error occurred. Cannot create an 
automatic instance. See the Windows Application event log for error details. 
)] 
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) +1394 
System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions 
options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool 
pool, DbConnection owningConnection, DbConnectionOptions userOptions) +1120 
System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool 
pool, DbConnection owningObject, DbConnectionOptions options, DbConnectionPoolKey 
poolKey, DbConnectionOptions userOptions) +70 
System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection 
owningObject, DbConnectionOptions userOptions, DbConnectionInternal 
oldConnection) +964 
System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection 
owningObject, DbConnectionOptions userOptions, DbConnectionInternal 
oldConnection) +114 
System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection 
owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, 
Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& 
connection) +1631 
System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection 
owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, 
DbConnectionInternal& connection) +117 
System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection 
owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions 
userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& 
connection) +267 
System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection 
outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, 
DbConnectionOptions userOptions) +318 
System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource`1 
retry) +211 
System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry) 
+393 
System.Data.SqlClient.SqlConnection.Open() +122 
System.Data.Entity.Infrastructure.Interception.InternalDispatcher`1.Dispatch(TTarget 
target, Action`2 operation, TInterceptionContext interceptionContext, Action`3 executing, 
Action`3 executed) +104 
System.Data.Entity.Infrastructure.Interception.DbConnectionDispatcher.Open(DbConnection connection, DbInterceptionContext interceptionContext) +442 
System.Data.Entity.SqlServer.<>c__DisplayClass33.<UsingConnection>b__32() 
+562 
System.Data.Entity.SqlServer.<>c__DisplayClass1.<Execute>b__0() +16 
System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute(Func`1 
operation) +229 
System.Data.Entity.SqlServer.SqlProviderServices.UsingMasterConnection(DbConnection 
sqlConnection, Action`1 act) +916 
System.Data.Entity.SqlServer.SqlProviderServices.CreateDatabaseFromScript(Nullable`1 
commandTimeout, DbConnection sqlConnection, String createDatabaseScript) +111 
System.Data.Entity.SqlServer.SqlProviderServices.DbCreateDatabase(DbConnection 
connection, Nullable`1 commandTimeout, StoreItemCollection storeItemCollection) +203 
System.Data.Entity.Migrations.Utilities.DatabaseCreator.Create(DbConnection 
connection) +129 
System.Data.Entity.Migrations.DbMigrator.EnsureDatabaseExists(Action 
mustSucceedToKeepDatabase) +172 
System.Data.Entity.Migrations.DbMigrator.Update(String targetMigration) +110 
System.Data.Entity.Internal.DatabaseCreator.CreateDatabase(InternalContext 
internalContext, Func`3 createMigrator, ObjectContext objectContext) +118 
System.Data.Entity.Database.Create(DatabaseExistenceState existenceState) 
+284 
System.Data.Entity.CreateDatabaseIfNotExists`1.InitializeDatabase(TContext 
context) +185 
System.Data.Entity.Internal.InternalContext.PerformInitializationAction(Action action) 
+72 
System.Data.Entity.Internal.InternalContext.PerformDatabaseInitialization() 
+502 
System.Data.Entity.Internal.RetryAction`1.PerformAction(TInput input) +177 
System.Data.Entity.Internal.LazyInternalContext.InitializeDatabaseAction(Action`1 
action) +273 
System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type 
entityType) +38 
System.Data.Entity.Internal.Linq.InternalSet`1.Initialize() +77 
System.Data.Entity.Internal.Linq.InternalSet`1.get_InternalContext() +21 
System.Data.Entity.Infrastructure.DbQuery`1.System.Linq.IQueryable.get_Provider() +56 
System.Linq.Queryable.Where(IQueryable`1 source, Expression`1 predicate) +61 
BL.Facades.StatisticsFacade.GetDistributionData(String factorFamiliarName, 
Int32 versionID) +1396 
PL.Controllers.StatisticsController.Index() in C:\Users\Administrator\Downloads\MyFirstProject\MyFirstProject\PL\Controllers\StatisticsController.cs:19 
lambda_method(Closure , ControllerBase , Object[]) +87 
System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext 
controllerContext, IDictionary`2 parameters) +209 
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext 
controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) 
+35 
System.Web.Mvc.Async.AsyncControllerActionInvoker.<BeginInvokeSynchronousActionMethod>b__39(IAsyncResult asyncResult, ActionInvocation innerInvokeState) +39 
System.Web.Mvc.Async.WrappedAsyncResult`2.CallEndDelegate(IAsyncResult 
asyncResult) +67 
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult 
asyncResult) +42 
System.Web.Mvc.Async.AsyncInvocationWithFilters.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3d() +72 
System.Web.Mvc.Async.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f() +386 
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult) +42 
System.Web.Mvc.Async.<>c__DisplayClass2b.<BeginInvokeAction>b__1c() +30 
System.Web.Mvc.Async.<>c__DisplayClass21.<BeginInvokeAction>b__1e(IAsyncResult 
asyncResult) +186 
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult 
asyncResult) +38 
System.Web.Mvc.Controller.<BeginExecuteCore>b__1d(IAsyncResult asyncResult, 
ExecuteCoreState innerState) +29 
System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult 
asyncResult) +65 
System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +53 
System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult 
asyncResult) +36 
System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +38 
System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__5(IAsyncResult 
asyncResult, ProcessRequestState innerState) +44 
System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult 
asyncResult) +65 
System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +38 
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +399 
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& 
completedSynchronously) +137 

私は数週間のためにunsuccessfulyこのプロジェクトを展開しようとすると、実際にそれを成し遂げる必要があるのです。誰かが私に何を間違えているか教えてもらえますか?私は、データベースへの接続の詳細は、このエラーが言う

+0

Visual Studioはすべてあなたの権限であなたのユーザーアカウントで実行します。 IISは独自のアクセス許可セットを持つ別のユーザーアカウントで実行されます。 IISアプリケーションユーザーに、Webで実行したいすべての作業を実行する権限があることを確認する必要があります。 –

+0

SQL Server Express 2014のLocalDBを変更して同じ例外が発生しました。次に、このソリューションを使用して権限を与えました。 https://blogs.msdn.microsoft.com/sqlexpress/2011/12/08/using-localdb-with-full-iis-part-2-instance-ownership/#OURIIS – Myoxidae

答えて

0

A network-related or instance-specific error occurred while establishing a connection to SQL Server.......

...まだそれを動作させることができなかった、intalledのVisual StudioずにSQL Server Expressの2014を使用して、それを配備行う試してみました。この前 が正しくありません。 を参照してください:https://www.connectionstrings.com/sql-server/

関連する問題