I am reading John M. Lee‘s Riemannian Manifolds: An Introduction to Curvature. In Lemma $5.2$, it is said that the following conditions are equivalent for a linear connection $\nabla$ on a Riemannian manifold:
(a) $\nabla$ is compatible with $g$.
i.e., for any vector fields $X,Y,Z$,
$$ \nabla_X g(Y,Z) = g(\nabla_X Y,Z) + g(Y,\nabla_X Z) $$
(b) $\nabla g\equiv 0.$
How do we go from (a) to (b) (and (b) to (a))?
Hint: Use Lemma $4.6$ (ii) (i.e. the formula displayed here) to deduce that
$$(\nabla_X g)(Y, Z) = \nabla_Xg(Y, Z) – g(\nabla_XY, Z) – g(Y, \nabla_XZ).$$
As $g(Y, Z)$ is a smooth function, $\nabla_Xg(Y, Z) = Xg(Y, Z)$ so the metric compatibility condition can also be written as
$$Xg(Y, Z) = g(\nabla_XY, Z) + g(Y, \nabla_XZ).$$