question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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 issue

Hello,

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:open
  • Created 2 years ago
  • Reactions:1
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
artemkovalyovcommented, Oct 11, 2021

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 and sap: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.

0reactions
marikanercommented, Jul 18, 2022

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Convention model builder - OData - Microsoft Learn
Convention model builder uses a set of pre-defined rules (called conventions) to help model builder identify Edm types, keys, associations, ...
Read more >
Common Schema Definition Language (CSDL) (OData ...
OData, short for Open Data Protocol, is an open protocol to allow the creation and consumption of queryable and interoperable RESTful APIs in...
Read more >
OData Common Schema Definition Language (CSDL) XML ...
The Common Schema Definition Language (CSDL) defines specific representations of the entity data model exposed by an OData service using, XML, JSON, ...
Read more >
OData V2 Model - Documentation - Demo Kit - SAPUI5 SDK
ODataModel #create triggers a POST request with the given initial data to the OData service to create an entity. This API does not...
Read more >
Entity Framework Core: `SqlNullValueException: Data is Null ...
The error message indicates that EF Core is trying to read string value for a required property, i.e. a property which should never...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found