  In this paper, the structure of a dark matter halo can be well described by
the mass model of M87 and the Einasto profile for the cold dark matter model,
i.e., $\rho_{\text{eina}} (r)=\rho_\text{e} \exp ( -2 \alpha ^{-1}
((r/r_\text{e})^\alpha -1 ) )$ (Wang et al. in Nature 585:39-42, 2020). Under
these conditions, we construct a solution of a static spherically symmetric
black hole in a dark matter halo. Then, using the Newman-janis algorithm, we
extend this static solution to the case of rotation, and obtain a solution for
the Kerr-like black hole. We prove that this solution of the Kerr-like black
hole is indeed a solution to the Einstein field equations. Finally, taking M87
as an example, we study and analyze some physical properties of this Kerr-like
black hole, and then compare them with the Kerr black hole. Particularly, from
the perspective of the black hole shadow and the fact that the Kerr-like black
hole and the Kerr black hole is distinguishable, we give the upper limit of the
shape parameter of the Einasto density profile, that is approximately
$\alpha<0.22$, which may provide a new method to further improve and perfect
the density profile of dark matter model. These research results for the black
hole in a dark matter halo may indirectly provide an effective method for
detecting the existence of dark matter.
