After creating a custom command, API and return entity, I was getting the following error when starting the commerce engine in debug mode.
The entity 'MyModel' does not have a key defined
at Microsoft.AspNetCore.OData.Builder.ODataModelBuilder.ValidateModel(IEdmModel model)
The fix was to add the [Key] attribute to one of the attributes of my model. This can be found under the
System.ComponentModel.DataAnnotations model.
public class ExtendedPricingDetail
{
[Key]
public string ProductId { get; set; }
public Decimal CurrentPrice { get; set; }
public Decimal OriginalPrice { get; set; }
public string PromotionCode { get; set; }
public string PromotionText { get; set; }
public bool OnSpecial { get; set; }
public ExtendedPricingDetail()
{
ProductId = string.Empty;
CurrentPrice = 0.00M;
OriginalPrice = 0.00M;
PromotionCode = string.Empty;
PromotionText = string.Empty;
OnSpecial = false;
}
}
No comments:
Post a Comment