The electrostatic continuum solvent model developed by Fattebert and Gygi is combined with a first-principles formulation of the cavitation energy based on a natural quantum-mechanical definition for the surface of a solute. Despite its simplicity, the cavitation contribution calculated by this approach is found to be in remarkable agreement with that obtained by more complex algorithms relying on a large set of parameters. Our model allows for very efficient Car-Parrinello simulations of finite or extended systems in solution, and demonstrates a level of accuracy as good as that of established quantum-chemistry continuum solvent methods. We apply this approach to the study of tetracyanoethylene dimers in dichloromethane, providing valuable structural and dynamical insights on the dimerization phenomenon.