A notable phenomenon in topological semimetals is the violation of Kohler$^,$s rule, which dictates that the magnetoresistance $MR$ obeys a scaling behavior of $MR = f(H/rho_0$), where $MR = [rho_H-rho_0]/rho_0$ and $H$ is the magnetic field, with $rho_H$ and $rho_0$ being the resistivity at $H$ and zero field, respectively. Here we report a violation originating from thermally-induced change in the carrier density. We find that the magnetoresistance of the Weyl semimetal, TaP, follows an extended Kohler$^,$s rule $MR = f[H/(n_Trho_0)]$, with $n_T$ describing the temperature dependence of the carrier density. We show that $n_T$ is associated with the Fermi level and the dispersion relation of the semimetal, providing a new way to reveal information on the electronic bandstructure. We offer a fundamental understanding of the violation and validity of Kohler$^,$s rule in terms of different temperature-responses of $n_T$. We apply our extended Kohler$^,$s rule to BaFe$_2$(As$_{1-x}$P$_x$)$_2$ to settle a long-standing debate on the scaling behavior of the normal-state magnetoresistance of a superconductor, namely, $MR$ ~ $tan^2theta_H$, where $theta_H$ is the Hall angle. We further validate the extended Kohler$^,$s rule and demonstrate its generality in a semiconductor, InSb, where the temperature-dependent carrier density can be reliably determined both theoretically and experimentally.