Using two different models from holographic quantum chromodynamics (QCD) we study the deconfinement phase transition in $2+1$ dimensions in the presence of a magnetic field. Working in 2+1 dimensions lead us to {sl exact} solutions on the magnetic field, in contrast with the case of 3+1 dimensions where the solutions on the magnetic field are perturbative. As our main result we predict a critical magnetic field $B_c$ where the deconfinement critical temperature vanishes. For weak fields meaning $B<B_c$ we find that the critical temperature decreases with increasing magnetic field indicating an inverse magnetic catalysis (IMC). On the other hand, for strong magnetic fields $B>B_c$ we find that the critical temperature raises with growing field showing a magnetic catalysis (MC). These results for IMC and MC are in agreement with the literature.