The OData generated client has no way to add the new dependent entity if it is defined in the EDMX as not creatable
See original GitHub issueHello,
I need to add the new dependent entity to the root entity. In the EDMX file the dependent entity is flagged as not creatable:
<EntityContainer Name="cds_lmd_route_Entities" m:IsDefaultEntityContainer="true"> <EntitySet Name="Route" EntityType="cds_lmd_route.RouteType" /> //Root <EntitySet Name="CustomerVisit" EntityType="cds_lmd_route.CustomerVisitType" sap:creatable="false"> //Child </EntityContainer>
According to the documentation: https://sap.github.io/cloud-sdk/docs/js/features/odata/use-odata-v2-type-safe-client-for-javascript-typescript#create-as-child-of
It can be done like this:
CustomerVisit.requestBuilder() .create(visit) .asChildOf( route, Route.TO_CUSTOMER_VISIT ) .execute(myDestination)
The problem is that the OData client-generated coding does not have create method.
So it is not clear how to add a new entity to the root.
Used workaround:
manually change the EDMX file to make entity CustomerVisit creatable:
<EntityContainer Name="cds_lmd_route_Entities" m:IsDefaultEntityContainer="true"> <EntitySet Name="Route" EntityType="cds_lmd_route.RouteType" /> //Root <EntitySet Name="CustomerVisit" EntityType="cds_lmd_route.CustomerVisitType" sap:creatable="true"> //Child </EntityContainer>
Regenerate the OData client and it works.
Still very inconvenient always to remember that you need to change the EDMX file to make it work.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:5 (3 by maintainers)
This sounds to me like a correct behavior if the entity is marked as
sap:creatable="false"
. Your workaround also proves it. Where have you got a specification? If the service allows the creation of that entity then the specification is incorrect. As far as I remember we respect some vendor properties andsap:creatable
is one of them.I think it would be a good idea to clarify with the service owner what is the real intended behavior and ask them to fix the specification. Let us know what service that is.
Hey @yurecz,
I found some more details on annotations. I would like to implement this, however this is a bigger chunk and will definitely take a lot of time until it will be available for you. I hope for now you can work with the workaround.