执行命令定义时发生错误 - WCF

时间:2015-07-03 06:42:30

标签: c# asp.net entity-framework wcf appharbor

我已经更新了我的模型并完成了重建项目(如stackoverflow所示),但没有任何好处。

我的ASP.NET wcf webservice在本地主机上正常运行。但是当我将它上传到AppHarbor(免费的asp.net网络托管服务)时,我得到了一个例外(我这样称呼http://pizzaapp.apphb.com/Service1.svc/Login/123/1)我无法理解(如下所示)。这在我的本地主机上完美运行,那么上传后的问题是什么?

  

请求错误服务器在处理请求时遇到错误。   异常消息是'执行时出错   命令定义。有关详细信息,请参阅内部异常。'。见服务器   记录更多详细信息。异常堆栈跟踪是:

     

在   System.Data.Entity.Core.EntityClient.Internal.EntityCommandDefinition.ExecuteStoreCommands(EntityCommand   entityCommand,CommandBehavior behavior)at   System.Data.Entity.Core.Objects.Internal.ObjectQueryExecutionPlan.Execute [TResultType](ObjectContext的   context,ObjectParameterCollection parameterValues)at   System.Data.Entity.Core.Objects.ObjectQuery 1.<>c__DisplayClass3.<GetResults>b__2() at System.Data.Entity.Core.Objects.ObjectContext.ExecuteInTransaction[T](Func 1   func,IDbExecutionStrategy executionStrategy,Boolean   startLocalTransaction,Boolean releaseConnectionOnSuccess)at   System.Data.Entity.Core.Objects.ObjectQuery 1.<>c__DisplayClass3.<GetResults>b__1() at System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute[TResult](Func 1   操作)   System.Data.Entity.Core.Objects.ObjectQuery 1.GetResults(Nullable 1   forMergeOption)at   System.Data.Entity.Core.Objects.ObjectQuery 1.<System.Collections.Generic.IEnumerable<T>.GetEnumerator>b__0() at System.Lazy 1.CreateValue()在System.Lazy 1.LazyInitValue() at System.Lazy 1.get_Value()at   System.Data.Entity.Internal.LazyEnumerator 1.MoveNext() at System.Linq.Enumerable.SingleOrDefault[TSource](IEnumerable 1来源)   在   System.Data.Entity.Core.Objects.ELinq.ObjectQueryProvider.b__2 [TResult](IEnumerable的1 sequence) at System.Data.Entity.Core.Objects.ELinq.ObjectQueryProvider.ExecuteSingle[TResult](IEnumerable 1   查询,表达式queryRoot)at   System.Data.Entity.Core.Objects.ELinq.ObjectQueryProvider.System.Linq.IQueryProvider.Execute [TResult](式   表达)at   System.Data.Entity.Internal.Linq.DbQueryProvider.Execute [TResult](式   表达)at   System.Linq.Queryable.SingleOrDefault [TSource](IQueryable`1 source)at   WcfServicePizza.Service1.Login(String phoneNo,String password)in   d:\ temp \ lmtrshzg.bwx \ input \ WcfServicePizza \ Service1.svc.cs:第37行at   SyncInvokeLogin(Object,Object [],Object [])at   System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(对象   实例,对象[]输入,对象[]&amp;输出)   System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc&安培;   rpc)at   System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc&安培;   rpc)at   System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage41(MessageRpc&安培;   rpc)at   System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage4(MessageRpc&安培;   rpc)at   System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc&安培;   rpc)at   System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage3(MessageRpc&安培;   rpc)at   System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage2(MessageRpc&安培;   rpc)at   System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage11(MessageRpc&安培;   rpc)at   System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage1(MessageRpc&安培;   rpc)at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean   isOperationContextSet)

webservice接口的代码

    [OperationContract]
    [WebInvoke(UriTemplate="SignUp",
        Method="POST",
        BodyStyle=WebMessageBodyStyle.WrappedRequest,
        ResponseFormat=WebMessageFormat.Json,
        RequestFormat=WebMessageFormat.Json)]
    bool SignUp(Customer customer);

目前在服务器上运行的实现代码是:

    public bool Login(string phoneNo, string password)
    {
        decimal phoneNoDecimal = Decimal.Parse(phoneNo);
        DatabasePizzaEntities db = new DatabasePizzaEntities();
        Customer customer = db.Customers.Where(c => c.PhoneNo==phoneNoDecimal && c.Password == password).SingleOrDefault();
        if (customer == null)
            return false;
        return true;
    }

INNER EXCEPTION:

  

Data.SqlClient.SqlException(0x80131904):无效的对象名称   &#39; dbo.Customer&#39;。\ u000d \ u000a at   System.Data.SqlClient.SqlConnection.OnError(SqlException异常,   Boolean breakConnection,Action 1 wrapCloseInAction)\u000d\u000a at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action 1   wrapCloseInAction)\ u000d \ u000a at   System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject   stateObj,Boolean callerHasConnectionLock,Boolean   asyncClose)\ u000d \ u000a at   System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior,   SqlCommand cmdHandler,SqlDataReader dataStream,   BulkCopySimpleResultSet bulkCopyHandler,TdsParserStateObject   stateObj,布尔&amp; dataReady)\ u000d \ u000a at   System.Data.SqlClient.SqlDataReader.TryConsumeMetaData()\ u000d \ u000a
  在System.Data.SqlClient.SqlDataReader.get_MetaData()\ u000d \ u000a at   System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds,   RunBehavior runBehavior,String resetOptionsString)\ u000d \ u000a at   System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(的CommandBehavior   cmdBehavior,RunBehavior runBehavior,Boolean returnStream,Boolean   async,Int32超时,任务&amp; task,Boolean asyncWrite,SqlDataReader   ds)\ u000d \ u000a at   System.Data.SqlClient.SqlCommand.RunExecuteReader(的CommandBehavior   cmdBehavior,RunBehavior runBehavior,Boolean returnStream,String   方法,TaskCompletionSource 1 completion, Int32 timeout, Task& task, Boolean asyncWrite)\u000d\u000a at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)\u000d\u000a at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)\u000d\u000a at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior)\u000d\u000a at System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior)\u000d\u000a at System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.<>c__DisplayClassb.<Reader>b__8()\u000d\u000a at System.Data.Entity.Infrastructure.Interception.InternalDispatcher 1.Dispatch [TInterceptionContext,TResult](Func 1 operation, TInterceptionContext interceptionContext, Action 1   执行,Action`1执行)\ u000d \ u000a at   System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.Reader(的DbCommand   command,DbCommandInterceptionContext interceptionContext)\ u000d \ u000a   在   System.Data.Entity.Internal.InterceptableDbCommand.ExecuteDbDataReader(的CommandBehavior   行为)\ u000d \ u000a at   System.Data.Common.DbCommand.ExecuteReader(的CommandBehavior   行为)\ u000d \ u000a at   System.Data.Entity.Core.EntityClient.Internal.EntityCommandDefinition.ExecuteStoreCommands(EntityCommand   entityCommand,CommandBehavior   行为)\ u000d \ u000aClientConnectionId:2c6eb8fd-ce5b-4866-8dc7-5ff565fb11d5 \ u000d \ u000aError   数:208,状态:1,类别:16&#34;

1 个答案:

答案 0 :(得分:1)

本地主机和AppHarbor之间的区别在于您要连接的数据库。

错误消息是:

An error occurred while executing the command definition

这通常是数据库架构和映射文件之间的问题。

AppHarbor中的数据库架构是否与本地数据库中的架构不同?

这是“无效的对象名称”,可以是:

  • Customer表不存在,
  • 或者它不在dbo架构中,
  • 或连接字符串中的用户无权访问该表。
相关问题