  We study the generation of vortices in rotating Bose--Einstein condensates, a
situation which has been realized in a recent experiment (K. W. Madison, F.
Chevy, W. Wohlleben, J. Dalibard, Phys. Rev. Lett. {\bf 84} 806 (2000)). By
combining a linear stability analysis with the global optimization of the
nonlinear free energy functional, we study the regimes that can be reached in
current experiments. We find a hysteresis phenomenon in the vortex nucleation
due to the metastabilization of the vortexless condensate. We also prove that
for a fast enough rotating trap the ground state of the condensate hosts one or
more bent vortex lines.
