我在部署到Azure时正在运行错误。 我直接从我的web配置文件中取得了连接字符串,该文件在本地测试时起作用,并且我将其修改为适合我的Azure部署,但随后出现错误。Azure中的实体框架连接字符串错误
以下是原始连接字符串我的本地机器的工作原理:
<add name="DataEntities" connectionString="metadata=res://*/Models.FirearmModels.csdl|res://*/Models.FirearmModels.ssdl|res://*/Models.FirearmModels.msl;provider=System.Data.SqlClient;provider connection string="data source=(LocalDB)\v11.0;attachdbfilename=|DataDirectory|\Data.mdf;integrated security=True;connect timeout=30;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
下面是Azure的修改后的连接字符串:
<add name="DataEntities" connectionString="metadata=res://*/Models.FirearmModels.csdl|res://*/Models.FirearmModels.ssdl|res://*/Models.FirearmModels.msl;provider=System.Data.SqlClient;provider connection string="data source=tcp:owm5115h08.database.windows.net,1433;Initial Catalog=diafirearmserver;User ID=userid;Password=userpass;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
可能有人请告诉我是什么我做错了,我失去了什么,在让这个工作?
在此先感谢。
PS:这里是错误的截图,当我在Azure上运行它,我得到: http://i693.photobucket.com/albums/vv293/saturobi360/EntityConnString_Error_zpsyrt1f9jg.jpg
我对图像质量的歉意。 我道歉:本地
<Error>
<Message>An error has occurred.</Message>
<ExceptionMessage>
An error occurred while executing the command definition. See the inner exception for details.
</ExceptionMessage>
<ExceptionType>
System.Data.Entity.Core.EntityCommandExecutionException
</ExceptionType>
<StackTrace>
at System.Data.Entity.Core.EntityClient.Internal.EntityCommandDefinition.<ExecuteStoreCommandsAsync>d__c.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Data.Entity.Core.Objects.Internal.ObjectQueryExecutionPlan.<ExecuteAsync>d__0`1.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Data.Entity.Utilities.TaskExtensions.CultureAwaiter`1.GetResult() at System.Data.Entity.Core.Objects.ObjectContext.<ExecuteInTransactionAsync>d__3d`1.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.<ExecuteAsyncImplementation>d__9`1.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Data.Entity.Utilities.TaskExtensions.CultureAwaiter`1.GetResult() at System.Data.Entity.Core.Objects.ObjectQuery`1.<GetResultsAsync>d__e.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Data.Entity.Utilities.TaskExtensions.CultureAwaiter`1.GetResult() at System.Data.Entity.Internal.LazyAsyncEnumerator`1.<FirstMoveNextAsync>d__0.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Data.Entity.Infrastructure.IDbAsyncEnumerableExtensions.<FirstOrDefaultAsync>d__25`1.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at DIA_FirearmsAPIversion2.Controllers.FirearmsController.<GetFirearm>d__2.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Threading.Tasks.TaskHelpersExtensions.<CastToObject>d__3`1.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Web.Http.Controllers.ApiControllerActionInvoker.<InvokeActionAsyncCore>d__0.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>d__2.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Web.Http.Controllers.AuthenticationFilterResult.<ExecuteAsync>d__0.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__1.MoveNext()
</StackTrace>
<InnerException>
<Message>An error has occurred.</Message>
<ExceptionMessage>Invalid object name 'dbo.Firearms'.</ExceptionMessage>
<ExceptionType>System.Data.SqlClient.SqlException</ExceptionType>
<StackTrace>
at System.Data.SqlClient.SqlCommand.<>c__DisplayClass16.<ExecuteDbDataReaderAsync>b__17(Task`1 result) at System.Threading.Tasks.ContinuationResultTaskFromResultTask`2.InnerInvoke() at System.Threading.Tasks.Task.Execute() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Data.Entity.Core.EntityClient.Internal.EntityCommandDefinition.<ExecuteStoreCommandsAsync>d__c.MoveNext()
</StackTrace>
</InnerException>
我原来的连接字符串:
<add name="DefaultConnection" connectionString="Data Source=(LocalDb)\v11.0;AttachDbFilename=|DataDirectory|\aspnet-DIA_FirearmsAPIversion2-20151118042347.mdf;Initial Catalog=aspnet-DIA_FirearmsAPIversion2-20151118042347;Integrated Security=True" providerName="System.Data.SqlClient" />
<add name="DataEntities" connectionString="metadata=res://*/Models.FirearmModels.csdl|res://*/Models.FirearmModels.ssdl|res://*/Models.FirearmModels.msl;provider=System.Data.SqlClient;provider connection string="data source=(LocalDB)\v11.0;attachdbfilename=|DataDirectory|\Data.mdf;integrated security=True;connect timeout=30;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
<add name="DIA_FirearmsAPIversion2Context" connectionString="Data Source=(localdb)\v11.0; Initial Catalog=DIA_FirearmsAPIversion2Context-20151118164215; Integrated Security=True; MultipleActiveResultSets=True; AttachDbFilename=|DataDirectory|DIA_FirearmsAPIversion2Context-20151118164215.mdf" providerName="System.Data.SqlClient" />
我的连接字符串天青:
<add name="DefaultConnection" connectionString="Data Source=tcp:owm5115h08.database.windows.net,1433;Initial Catalog=diafirearmserver;User Id=username;Password=userpassword" providerName="System.Data.SqlClient" />
<add name="DataEntities" connectionString="metadata=res://*/Models.FirearmModels.csdl|res://*/Models.FirearmModels.ssdl|res://*/Models.FirearmModels.msl;provider=System.Data.SqlClient;provider connection string="data source=tcp:owm5115h08.database.windows.net,1433;Initial Catalog=diafirearmserver;User ID=username;Password=userpassword;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
<add name="DIA_FirearmsAPIversion2Context" connectionString="Data Source=tcp:owm5115h08.database.windows.net,1433;Initial Catalog=diafirearmserver;User Id=username;Password=userpassword" providerName="System.Data.SqlClient" />
在我的手机上,图像很糟糕。将例外剪切并粘贴到您的问题中,让所有相关人员的生活更轻松。 –
@BrendanGreen,我对截图的图像质量表示歉意。我更新了错误的原始帖子。 – saturobi360
在发布到Azure时,您可以选择运行待定迁移,是否选中了此复选框?也可以尝试连接到SQL数据库,看看什么是真正的存在(表)... – Milen