2015-05-08 73 views
2

我有和現有的數據庫有3個表和它們之間的關係。其中兩個表具有名爲「Id」的主鍵列是整數列。第三個表具有一個複合主鍵,該主鍵由與其他兩個表(鏈接表或多對多)中的每一個有關的外鍵組成。現有數據庫已遷移到Azure並由Azure移動服務使用 - 標識屬性異常

我設置了一個新的Azure移動服務,並將此數據庫指定爲服務數據的來源。我爲.NET中的服務構建了控制器,模型和數據對象(DTO)。一切看起來正確的,但是當我試圖從任何表中請求數據,我得到這個錯誤:

{ 
message: "The query specified in the URI is not valid. Property 'Id' is of an unrecognized EdmPropertyKind." 
exceptionMessage: "Property 'Id' is of an unrecognized EdmPropertyKind." 
exceptionType: "Microsoft.Data.OData.ODataException" 
stackTrace: " at Microsoft.Data.OData.Query.SyntacticAst.SelectPathSegmentTokenBinder.TryBindAsDeclaredProperty(PathSegmentToken tokenIn, IEdmEntityType entityType, ODataPathSegment& segment) at Microsoft.Data.OData.Query.SyntacticAst.SelectPathSegmentTokenBinder.ConvertNonTypeTokenToSegment(PathSegmentToken tokenIn, IEdmModel model, IEdmEntityType entityType) at Microsoft.Data.OData.Query.SyntacticAst.SelectPropertyVisitor.ProcessTokenAsPath(NonSystemToken tokenIn) at Microsoft.Data.OData.Query.SyntacticAst.SelectPropertyVisitor.Visit(NonSystemToken tokenIn) at Microsoft.Data.OData.Query.SyntacticAst.NonSystemToken.Accept(IPathSegmentTokenVisitor visitor) at Microsoft.Data.OData.Query.SyntacticAst.SelectBinder.Bind(SelectToken tokenIn) at Microsoft.Data.OData.Query.SelectExpandSemanticBinder.Parse(IEdmEntityType elementType, IEdmEntitySet entitySet, ExpandToken expandToken, SelectToken selectToken, ODataUriParserConfiguration configuration) at Microsoft.Data.OData.Query.ODataUriParser.ParseSelectAndExpandImplementation(String select, String expand, IEdmEntityType elementType, IEdmEntitySet entitySet) at System.Web.Http.OData.Query.SelectExpandQueryOption.get_SelectExpandClause() at System.Web.Http.OData.Query.Validators.SelectExpandQueryValidator.Validate(SelectExpandQueryOption selectExpandQueryOption, ODataValidationSettings validationSettings) at System.Web.Http.OData.Query.SelectExpandQueryOption.Validate(ODataValidationSettings validationSettings) at System.Web.Http.OData.Query.Validators.ODataQueryValidator.Validate(ODataQueryOptions options, ODataValidationSettings validationSettings) at System.Web.Http.OData.Query.ODataQueryOptions.Validate(ODataValidationSettings validationSettings) at System.Web.Http.OData.EnableQueryAttribute.ValidateQuery(HttpRequestMessage request, ODataQueryOptions queryOptions) at System.Web.Http.OData.EnableQueryAttribute.ExecuteQuery(Object response, HttpRequestMessage request, HttpActionDescriptor actionDescriptor) at System.Web.Http.OData.EnableQueryAttribute.OnActionExecuted(HttpActionExecutedContext actionExecutedContext)" 
} 

有誰知道我做錯了嗎?

回答

3

爲了訪問來自Azure的移動服務數據庫的每個表必須符合以下要求:

  • The table must be in the schema of your Mobile Service (the schema is the name of your Mobile Service)
  • The table must have an identity column called ‘id’ and it must be all lower case letters

所以,它聽起來就像你需要我)確保2臺帶有id主鍵是設置爲標識字段,並ii)向您的第三個表添加id主鍵(這是一個標識),您可以基本上忽略您的使用情況,但會使Azure移動服務接受它。出於性能考慮,您還可以爲舊主鍵創建索引。

我建議檢討this blog post