I'll show you how it's done in Mendix, hopefully that will help you to understand how to implement it for SQL server.
When using External Entities and OData APIs in Mendix to Mendix communication, the service will generate the id when the API is requested to save a new resource. The response will include the server generated Id and it will be provided to the client in the response payload. So the client immediately knows the ID generated by the service.
Here's an mendix to mendix example.
Here we have one normal persistent entity with an autogenerated CustomerId attribute. This is exposed as an OData resource, and consumed in the second domain model using an external entity. As illustrated here, the server side entity contains an autonumber, the client side just sees this as a long value.
When creating a new customer in the client, the user provides all fields except customer id. This data is then send to the API with the microflow shown here using the send customers activity. This activity automatically detects the customer id provided in the response by the service, and by selecting 'refresh in client' the data in the client webpage will automatically show the customer id generated by the service.
You can see this behavior by setting the log level of OData publish and OData consume to Trace. The next screenshot shows the API call with the data for the new object. This doesn't contain a customer id.
This next screenshot shows that the response contains the generated customer id.
If your SQL Server OData API provides the same information in the response for the POST operation, this will be used automatically by mendix to receive the generated id.
We use ODATA service concept to connect to SQL Server. I still did not get it . My external table has ID as identify column as primary key. SQL server automatically creates identify ID whenever we insert a record. My question is how to get this ID as a column from the external entity after it is created ? Do I get ID in the latest "latestHttpResponse"?