automatize primary key change type to avoid error when deployed

By Luciano Schiavo on 13 Apr 2014
During development is common to change some data types in the tables and sometime in PKs. When it occurs the 1-click shows error.  Like that :

Database Upgrade Error

Could not create / change primary key in 'OSUSR_k1p_Funcionario' table. Inconsistent database table and entity primary key definitions.


Publishing Error

Unable to upgrade database schema. Error trying to change database field 'OSUSR_k1p_Funcionario.ID' type (New Def: INT Mandatory in DB; DB Def: NVARCHAR(20) Mandatory in DB).
Exception: The object 'OSPRK_OSUSR_K1P_FUNCIONARIO' is dependent on column 'ID'.
ALTER TABLE ALTER COLUMN ID failed because one or more objects access this column.
SQL: alter table "WSY9NZ014"."DBO"."OSUSR_K1P_FUNCIONARIO" alter column "ID" INT;

J.14 Apr 2014

How can one figure out what the mapping should be?