If you have a document library or list, that contains a BDC column, you mig th run into updating the value of the primary key column programatically .If you try to do this the regular way,k you will not receive an error, but the new value will never show up in the row.
AnSPFile.Item["MyPrimaryBDCColumnsName"] = 1;

Instead you need to seek out the internal name of the column your trying to modify. You can do this easily by iterating over the columns of the list. Once you have located the internal name of the column, use that as the indexer for the row, and us the little documented class EntityInstanceIdEncoder to convert your new value into a BDC formatted value.

An example of using EntityInstanceIdEncoder.

AnSPFile.Item["MyPrimaryBDCColumnsInternalName"] = EntityInstanceIdEncoder.EncodeEntityInstanceId(new object[] { "1" });

You can quickly see if a column contains BDC encoded information by looking at the actual data (programatically) of the column. If the values look a bit like “_xxx30935” its probably a BDC encoded column.
Note: In the regular list view interface, Sharepoint will display a user friendly interpretation of the BDC data.

The EntityInstanceIdEncoder has a second function which will convert BDC encoded data back to its normal form.

object[] decoded = EntityInstanceIdEncoder.DecodeEntityInstanceId(source);

The EntityInstanceIdEncoder has a third function which you can use to tell if a column contains BDC encoded data or not

EntityInstanceIdEncoder.IsEncodedIdentifier (Convert.ToString(AnSPFile.Item[ "MyPrimaryBDCColumnsInternalName"])

One caveat to this method is that it will return false if the value of the current row is null, even if all other rows in the column contain encoded bdc information.

Hopefully this will help others who are faced with modifying a BDC column programatically and cannot find a lot of documentation on the subject in the Sharepoint documentation.