OData / odata.net

ODataLib: Open Data Protocol - .NET Libraries and Frameworks
https://docs.microsoft.com/odata
Other
686 stars 349 forks source link

When using the OData Client for v4 to create/post a new entity we are not getting the auto-generated (auto-incremented) ID/Key back from the service. #775

Open philcarbone opened 7 years ago

philcarbone commented 7 years ago

When using the OData Client for v4 to create/post a new entity we are not getting the auto-generated (auto-incremented) ID/Key back from the service. When we create the new entity, we have no ID assigned (it is an 'int' so the value is '0'). After calling SaveChanges the result JSON response has the new auto-assigned id (e.g. '4662'). The issue is that the Entity on the client side still has '0' for its ID (it's not mapped back to the orig. entity).

I also asked for help on Stackoverflow: http://stackoverflow.com/questions/42908236/when-using-the-odata-client-for-v4-to-create-post-a-new-entity-we-are-not-gettin

Assemblies affected

Reproduce steps

Expected result

The newly created (and saved) entity will have the ID updated to match the server-side response (JSON) that came back to the client.

Actual result

JSON response form the server-side has the correct ID, but the Entity on the client-side is never updated with this new information.

tchuan commented 7 years ago

@philcarbone I encountered the same issue, do you have a temp solution for this?

philcarbone commented 6 years ago

No response or work around yet. I may just add a new column called CorrelationId and insert a Guid from the client so that the know what the Id is. Not ideal, but Don't know what to do without a fix in the OData client.

earloc commented 6 years ago

please see my answer on SO

Mek7 commented 9 months ago

@earloc That is what I also have and doesn't work - client-side entity ID is always 0, despite the entity being returned from server in the body of HTTP Created result.