[英]System.ArgumentException: The table type parameter must have a valid type name
[英]OData with Mongo: System.ArgumentException: 'The property 'Id' on type 'Item' must be a Complex property. (Parameter 'propertyInfo')'
我正在嘗試使用OData
和Mongo
配置.net core
。
我收到此錯誤: System.ArgumentException: 'The property 'Id' on type 'Item' must be a Complex property. (Parameter 'propertyInfo')'
System.ArgumentException: 'The property 'Id' on type 'Item' must be a Complex property. (Parameter 'propertyInfo')'
這是我的配置:
services.AddControllers(options =>
{
// something here
})
.AddOData(opt =>
{
opt.Count()
.Filter()
.Expand()
.Select()
.OrderBy()
.SetMaxTop(5000)
.AddRouteComponents("odata", GetEdmModel());
opt.TimeZone = TimeZoneInfo.Utc;
});
public static IEdmModel GetEdmModel()
{
var builder = new ODataConventionModelBuilder();
var entitySetConfiguration = builder.EntitySet<Item>("Item");
entitySetConfiguration.EntityType.HasKey(entity => entity.Id);
return builder.GetEdmModel();
}
我的實體:
public class Item : Document
{
public string SubCategory { get; set; }
public string ProductCode { get; set; }
public string Name { get; set; }
public string Description { get; set; }
}
public abstract class Document : IDocument
{
public ObjectId Id { get; set; }
public DateTime CreatedAt => Id.CreationTime;
}
public abstract class Document : IDocument
{
//...
public string IdStr => Id.ToString();
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.