Melabs manual says

Flash program writes must be enabled in the configuration for the PICmicro MCU at device programming time for ERASECODE to be able to erase.

Have you done this when programming the pic?