My macbook pro mid-2012 works fine with my iMac 2009. It depends on the display port compatibility see item 4 in this link:
Apple TDM mode compatability
So for example an earlier MBP without a Thunderbolt port, will not work with a later iMac that has a Thunderbolt port, although the reverse is fine.
I would expect MBP's after 2012 to work ok though. You need to press Command + F2 together on the iMac keyboard. If your keyboard settinhs are default, Fn keys are set to use the advanced functions, in which case you need to press Command+Fn+F2