Ok, but you had these 2 lines:
detailEntity.SetRelatedEntity(productVersion, "ProductVersion");
detailEntity.SetNewFieldValue("ProductVersionID", productVersionID);
the first line sets the related entity. If productVersion.ProductVersionID is different from productVersionID, it will reset the reference in the second line, if they're the same, it will be a no-op. In your second posting, you show that the value is indeed the same, so by using detailEntity.SetRelatedEntity() you already set the related entity AND because productVersion is not new, it will sync the FK in detailEntity with the PK of productVersion as well, effectively setting detailEntity.ProductVersionID.
Saving detailEntity should then result in an updated detailEntity in the db. So with the single line:
detailEntity.SetRelatedEntity(productVersion, "ProductVersion");
you should have what you want. If you step over that line, detailEntity.ProductVersionID should be equal to the value of productVersionID, is that correct?