Error rebuilding Sitecore Commerce ServiceProxy in Sitecore Commerce 8.2.1

When rebuilding the Sitecore Commerce ServiceProxy, you may get an error similar to the following:

Compiling transformation: The type or namespace name 'Values' does not exist in the namespace 'Microsoft.OData.Edm' (are you missing an assembly reference?)

odata_errors

At first I thought I hadn't installed the OData v4 Client Code Generator extension in Visual Studio. However, I checked and it was installed.

The cause

After digging around, I found out that the latest version of the OData v4 Client Code Generator extension (version 7.5) is not compatible with the older version of OData in the project since it's looking for a newer version of OData dlls and hence complaining that it can't find it.

The fix

I needed to install an older version (2.4) to make it work. After removing the existing extension, and installing version 2.4, everything worked like a charm.

You can download older versions of the extension here:
https://github.com/OData/lab/tree/Tools/Tools

Incorrect version of OData v4 Client Code Generator:

odata_7.5-1

Correct version OData v4 Client Code Generator:

odata_2.4-1