Congratulations, you're a smart flyer by checking out the price of both the "real" flight and the code-share flight.
Think of the code-share flight by carrier X subcontracting the job to carrier Y, the main carrier. Technically, carrier X and Y are still competitors. Any fare coordination will result in anti-trust suits (unless you get anti-trust immunity like NW/KL).
Depending on the agreement, you may or may not get miles.
e.g.
NW/KL -- You get mileage regardless of metal that you're flying.
CO/AF -- If you're a CO OP member, you MUST fly on a CO-coded ticket if you're flying on AF metal to get miles.
- Pat