I am using Sitecore Commerce Experience 9 update-2, and want to add a custom child component to an entity.

The Sitecore.Commerce.Core.Component has a Key annotation (of type System.ComponentModel.DataAnnotations).

namespace Sitecore.Commerce.Core
  public class Component

    public string Id { get; set; }


This key annotation makes OData to generate a EntityType for components (or sub-classes of Component, e.g. CustomComponent).

<EntityType Name="CustomComponent" BaseType="Sitecore.Commerce.Core.Component">
    <Property Name="FirstName" Type="Edm.String" />

OData generates a NavigationProperty for entity types, for example:

<NavigationProperty Name="Components" Type="Collection(CustomComponent)" />

Navigation properties are by default not handled by the OData server. Result of this is that child components (ChildComponents property on the Component class) cannot be easily added using the OOTB command controllers.

Only solution found so far is to implement a custom controller and method that adds a child component for a certain entity (e.g. an AddChildComponentToCart CommandController method).

Are there any other (cleaner, simpler) ways to add child components to an entity?

Any good reasons why a Component is not an OData complex type (this could be achieved by not having the [Key] annotation on the Component class)?

1 Answer 1


I passed this over to the Product Team to comment on this, and the response was.....

There is not need for a custom controller, all components and child components can be expanded using odata expand option, e.g.


  • Tried that, but the serializer only de-serializes the base Component class for child components. Any clues how to solve that?
    – Joost
    Nov 26, 2018 at 13:55
  • Sitecore Support confirmed that the current approach for adding a custom component is to add your our Controller (and Block when necessary). Sadly not such a scalable approach.
    – Joost
    Dec 6, 2018 at 13:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.