Well what precisely do you dislike about what you're working on? If it is something external like the thought of failure, that might be solvable by some of the techniques others have mentioned here.
But a contrarian viewpoint: has it occurred to you that this project may be something that you thought you wanted to do, but never in fact actually wanted to do? Maybe you liked the thought of having done it, or maybe it was ok when you started it but now you don't like the meat of it.
And if is true that if you do not want to do this, that you will hate working in this field... perhaps you should reconsider fields. Usually attempts to change what you want are not successful.
Well what precisely do you dislike about what you're working on?
I just get bored after a while. Unless I'm in a slump, in which case I get bored immediately. I'm often in a slump.
If it is something external like the thought of failure,
It's definitely not that.
Perhaps the problem is more the lack of the thought of success. I tend towards living in the moment. It's not about the destination, it's about the journey. If I get bored of the journey, I stop. I do tend to work harder at the beginning, when I'm thinking about how awesome the end result would...
I have a master's project I'm having trouble working on. It's something I've wanted to do, and I even started working on, long before I started my master's degree. If I can't even enjoy that, then I'm doomed to spend eight hours a day doing something I hate for the rest of my life. Even if I manage to improve my willpower, I doubt I'll be very productive doing something I don't want to do.
Does anyone have any idea how I can enjoy working more?