Measuring the transport of electrons through a graphene sheet necessarily involves contacting it with metal electrodes. We study the adsorption of graphene on metal substrates using first-principles calculations at the level of density functional theory. The bonding of graphene to Al, Ag, Cu, Au and Pt(111) surfaces is so weak that its unique ultrarelativistic electronic structure is preserved. The interaction does, however, lead to a charge transfer that shifts the Fermi level by up to 0.5 eV with respect to the conical points. The crossover from p-type to n-type doping occurs for a metal with a work function ~5.4 eV, a value much larger than the work function of free-standing graphene, 4.5 eV. We develop a simple analytical model that describes the Fermi level shift in graphene in terms of the metal substrate work function. Graphene interacts with and binds more strongly to Co, Ni, Pd and Ti. This chemisorption involves hybridization between graphene $p_z$-states and metal d-states that opens a band gap in graphene. The graphene work function is as a result reduced considerably. In a current-in-plane device geometry this should lead to n-type doping of graphene.