I have several tables with an Integer primary key but they are not Identity columns so the KeyScheme was set to None (using EntityGenerator). In the FillEntity method setter wasn't getting called for these primary key columns. So I changed
if (field.IsPrimaryKey && (keyScheme == KeyScheme.Identity || keyScheme == KeyScheme.GUID))
so the else section will be executed for these PK columns.