JSON API 框架错误
Error with JSON API Framework
我有一个 .NET 解决方案,其中包含一个 DAL 项目和我的实体的配置,以及一个 Web API 项目,其中包含我从 SQL 服务器和我的控制器导入的所有实体。
当我 运行 项目出现此错误时(评论是与其他 2 个实体具有一对多关系的实体之一):
An exception of type
'JsonApiFramework.ServiceModel.ServiceModelException' occurred in
JsonApiFramework.Core.dll but was not handled in user code
Additional information:
JsonApiFramework.ServiceModel.Internal.ResourceType [clrType=Comment]
has missing ResourceIdentityInfo metadata. Ensure metadata is
configured correctly for the respective domain/schema.
我终于解决了这个问题。为了有效地使用 Json API,每个实体的 ID 都应该简单地命名为 id
。我名为 Business
的实体有一个名为 idBus
的 ID。因此,当我将名称 idBus
更改为 id
时,一切正常。
希望对大家有所帮助。
您也可以执行以下操作(如果您不想更改您的 ID 名称):
public class BusinessConfiguration : ResourceTypeBuilder<Business>
{
public BusinessConfiguration()
{
this.ResourceIdentity(x => x.idBus).SetApiType("business");
}
}
我有一个 .NET 解决方案,其中包含一个 DAL 项目和我的实体的配置,以及一个 Web API 项目,其中包含我从 SQL 服务器和我的控制器导入的所有实体。
当我 运行 项目出现此错误时(评论是与其他 2 个实体具有一对多关系的实体之一):
An exception of type 'JsonApiFramework.ServiceModel.ServiceModelException' occurred in JsonApiFramework.Core.dll but was not handled in user code
Additional information: JsonApiFramework.ServiceModel.Internal.ResourceType [clrType=Comment] has missing ResourceIdentityInfo metadata. Ensure metadata is configured correctly for the respective domain/schema.
我终于解决了这个问题。为了有效地使用 Json API,每个实体的 ID 都应该简单地命名为 id
。我名为 Business
的实体有一个名为 idBus
的 ID。因此,当我将名称 idBus
更改为 id
时,一切正常。
希望对大家有所帮助。
您也可以执行以下操作(如果您不想更改您的 ID 名称):
public class BusinessConfiguration : ResourceTypeBuilder<Business>
{
public BusinessConfiguration()
{
this.ResourceIdentity(x => x.idBus).SetApiType("business");
}
}