8. Given the equation $\sin x+\sqrt{3} \cos x=M$ has two distinct solutions in $\frac{\pi}{4} \leqslant x$ $\leqslant \frac{5 \pi}{4}$. Then the range of $M$ is
8. $\left(-2,-\frac{\sqrt{6}+\sqrt{2}}{2}\right]$.

The original expression can be transformed into $\sin \left(x+\frac{\pi}{3}\right)=\frac{M}{2}$. Using its graph and symmetry, we can determine that the equation $\sin x+\sqrt{3} \cos x=M$ has two different solutions in the interval $\frac{\pi}{4} \leqslant x \leqslant \frac{5 \pi}{4}$ when $M$ is in the range $\left(-2,-\frac{\sqrt{6}+\sqrt{2}}{2}\right]$.