It really depends on the context - as long as your example is concerned, the former is OK, the latter sounds very awkward.
But this awkwardness may not have anthing to do of with or without こと, probably because of the usate of 必要 or its combination with 食べる.
I'm not sure if this is a good example or not, but;
私は運転できる。
私は運転することができる。
The difference of nuance is almost nil with or without using こと.
Hope someone will come up with better examples and explanation...