To factor $ 5x^2y-x^2+5y-1 $ we can use factoring by grouping.
Group $ \color{blue}{ 5x^2y }$ with $ \color{blue}{ -x^2 }$ and $ \color{red}{ 5y }$ with $ \color{red}{ -1 }$ then factor each group.
$$ \begin{aligned} 5x^2y-x^2+5y-1 &= ( \color{blue}{ 5x^2y-x^2 } ) + ( \color{red}{ 5y-1 }) = \\ &= \color{blue}{ x^2( 5y-1 )} + \color{red}{ 1( 5y-1 ) } = \\ &= (x^2+1)(5y-1) \end{aligned} $$