Does electromagnet consume electricity?

Yes