differential geometry – Given a covariant derivative, is there a metric tensor that has the covariant derivative as the metric connection?

In differential geometry or general relativity, we usually think of the metric tensor $g_{mu nu}$ first and then introduce the metric connection.

However, I wonder if we can go reverse.

That is, let $M$ be a smooth manifold equipped with some nontrivial affine connection $nabla$. Then does there always exist a metric tensor $g_{mu nu}$ on $M$ that has $nabla$ as its metric connection?

I tried to figure this out myself but it is more confusing than expected. Could anyone help me?