2015-05-08 35 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

相关问题