If you put the two together and write f=c/λ then you can rearrange
mc2 = hc/λ to give λ = h/mc
DeBroglie did precisely this to come up with his hypothesis that λ = h/momentum
Which is the basis of wave - particle duality
The equation E=MC2 is used to find the energy content of some amount of mass. (Rest mass/invariant mass)
The equation E=hf is used to find the energy content a photon, where f = frequency of the photon.
Note that E=MC2 is actually part of a larger equation: E2=M2C4+P2C2, where P = momentum of the object. This allows you to find the energy content of an object based on its mass AND its motion relative to yourself.
as Emilyjoint is saying, if we take 'm' to be the 'relativistic mass', then e =mc2 and e = hf are both correct for a photon.
But as Drakkith is saying, if we take 'm' to be the 'rest mass', then the full equation is E2=M2C4+P2C2 and for a photon, the rest mass is zero, so E=PC for a photon.