If a metal and a semiconductor are connected, they are going to equilibrium. For this, the Fermi level has to be equal. So far I understood that this causes a charge exchange till said equilibrium has been reached. As a result, the band edges in the semiconductor are either bend up or downwards, depending on its doping. The Schottky barrier is the difference between the metal work function and the semiconductor electron affinity.
Why?
Why does the Schottky barrier need to remain constant?