Let $q=p^{e}$ be a prime power and $\ell$ be an integer with $0\leq \ell\leq e-1$. The $\ell$-Galois hull of classical linear codes is a generalization of the Euclidean hull and Hermitian hull. We provide a necessary and sufficient condition under which a codeword of a GRS code or an extended GRS code belongs to its $\ell$-Galois dual code, generalizing both the Euclidean case and Hermitian case in the literature. By using four different tools: 1) the norm mapping from $\mathbb{F}_{q}^{\ast}$ to $\mathbb{F}_{p^{\ell}}^{\ast}$; 2) the direct product of two cyclic subgroups; 3) the coset decomposition of a cyclic group; 4) an additive subgroup of $\mathbb{F}_{q}$ and its cosets, we construct eleven families of $q$-ary MDS codes with $\ell$-Galois hulls of arbitrary dimensions, and give the related eleven families of $[[n,k,d;c]]_{q}$ entanglement-assisted quantum error-correcting codes (EAQECCs) with relatively large minimum distance in the sense that $2d=n-k+2+c$. We show that developing the theory of $\ell$-Galois hulls of $q$-ary MDS codes in this paper
enables us to obtain new $q$-ary EAQECCs with different kinds of length sets via different $\ell$, where $2\ell\mid e$.