An electromagnet is a type of magnet where the magnetic field is produced by an electric current , typically winding a wire into a coil around a magnetic core, which can be switched on or off by controlling the current.