There are a number of things you have to do throughout the game in order to get everyone to survive the suicide mission. You have to get all three ship upgrades for the Normandy. (Shield, Armor, and Thanix Cannon Weapon) You have to complete the loyalty missions for all party members. You have to either use charm or intimidate conversation options in the scene where Jack and Miranda confront each other, same in the scene where Tali and Legion confront each other, in order to not lose loyalty on one of the two characters.
Finally, you have to pick specific squad members when you are given the option. The squad leader must be either Garrus or Miranda in both instances. The technician that goes into the vent must be either Tali, Legion, or Kasumi if you have her DLC. The squad member that forms the biotic shield must be either Samara/Morinth or Jack. You should pick Mordin to escort the additional crew members back to the Normandy, as he tends to die if you leave him to hold the line with the rest of your party when you go fight the Reaper Larva.
Do all these things and everyone will survive the suicide mission. Also if you want all of the abducted Normandy crew to survive, you have to go through the Omega 3 relay immediately after the Collectors abduct them. If you take too long, only Dr. Chakwas will survive, and only if you send someone to escort her back to the Normandy.
Did you complete Legion's loyalty mission? If you didn't that might get him killed. In the party selection screen, do all the characters have an orange circle under them? Any that don't, are not loyal and will probably get killed. You can try using Tali instead, I use her for that task all the time and she survives. I haven't actually tried Legion, but the guide for the suicide mission says that he will work for that task. You don't need the biotics, shield and accuracy upgrades for the characters to help them survive, just the ship upgrades.
i actually did complete legion's loyalty mission, but still he died , but then i chose zaeed to lead the groups both times ( maybe that had something to do with it.) in both the tries and i did not send an escort with dr. chakwas in the first try and sent thane with half the crew as an escort and mordin died.but wait if we complete legions loyalty mission the yeoman will die.
In order to save the entire crew, you have to hold off on getting the Reaper IFF until very, very late in the game. You basically have to do all the loyalty missions for all the other party members, then get the Reaper IFF. You will then have just enough time to do Legion's loyalty mission before the Collectors abduct your crew.