An electron lens – a novel instrument in accelerator physics to manipulate hadron beams with a magnetically confined electron beam - is under development at GSI, Darmstadt. It will be used to compensate the ion beam’s space charge by an overlapping electron beam and therefore may help to increase the intensity of primary beams in the low energy booster synchrotron SIS18 for FAIR. The main element of the lens is a solenoid with the longitudinal magnetic field of Bz = 600 mT, the diameter and the length of the good field domain of d= 80 mm and l = 300 mm. The overall length of the magnet including the iron housing is limited to L = 3360mm, corresponding to the available free space in a straight section of SIS18. To provide required parameters of the passing electron and ion beams the maximum field deviation from the average level in the magnet aperture is defined as ±5·10-4 relative units. The magnetic field in the solenoid aperture is expected to be ramped with the rate of up to 20 T/s. Consequently the eddy currents induced in the conducting elements of the magnet affects strongly the field characteristics. For achieving the required field quality inside the good field area it was necessary to solve several intrinsically linked problems: the choice of the proper winding stricture, especially in the end parts of the magnet; definition of the iron shield configuration; reducing the eddy currents in the solenoid construction elements as much as possible. To solve these problems we optimized the parameters of the magnet geometry. For this purpose we have combined the 2D finite element technology for the magnetic field modeling and the Nelder-Mead optimization strategy. The derived geometrical parameters ensured completely the required characteristics of the developed solenoid. Thorough investigation of its 3D model confirmed a quality and feasibility of the developed magnetic system.