  An explicit proof of the vanishing of the covariant divergence of the
energy-momentum tensor in modified theories of gravity is presented. The
gravitational action is written in arbitrary dimensions and allowed to depend
nonlinearly on the curvature scalar and its couplings with a scalar field. Also
the case of a function of the curvature scalar multiplying a matter Lagrangian
is considered. The proof is given both in the metric and in the first-order
formalism, i.e. under the Palatini variational principle. It is found that the
covariant conservation of energy-momentum is built-in to the field equations.
This crucial result, called the generalized Bianchi identity, can also be
deduced directly from the covariance of the extended gravitational action.
Furthermore, we demonstrate that in all of these cases, the freely falling
world lines are determined by the field equations alone and turn out to be the
geodesics associated with the metric compatible connection. The independent
connection in the Palatini formulation of these generalized theories does not
have a similar direct physical interpretation. However, in the conformal
Einstein frame a certain bi-metricity emerges into the structure of these
theories. In the light of our interpretation of the independent connection as
an auxiliary variable we can also reconsider some criticisms of the Palatini
formulation originally raised by Buchdahl.
