This is kinda like asking "I'm paper, how do I beat scissors?".
You switch to rock, of course.
The zeroeth thing you should have done already before this happens is set up some traps in your base - put down some turrets in unexpected corners, lay down some motion sensors, etcetera. They won't do much against a heavy, but they'll usually be enough to keep a light unit out. The flag takes priority of course, but if it's already well defended a quick turret near the generator doesn't hurt.
The first thing you should do, as soon as you notice an enemy swagging into your base, is to issue a quick VDG (voice commands - defend - generator). The worst that can happen is people will ignore it and you'll have to take care of the Eagle infestation yourself, but sometimes you can get a hand which is incredibly useful.
After that, your next step should be to stop being a technician. Techs - and especially techs in pajamas, who are loaded out for base defense - are squishy and have blunt teeth. You'll want to switch to a more combat oriented class, preferably one of the close-combat ones. That means (in approximate order of close combatness) Raider, Brute, Soldier, Infiltrator, Juggernaut, Devastator.
If the generators are still up, run to the nearest inventory station and change into your business attire. If they're not, set the switch up anyway - you can use the num pad for this, it's incredibly useful - and go after the jerk who just walked into your generator room; sure you'll probably die, but you'll come back better (faster stronger).
After that, it's just a matter of beating the invader(s) in close combat; you've got the advantage that you can come back a lot faster than they can, and that the rest of your team is going to really want the generators back up once they've been down for a while (make sure you you prod them with VDG/VDB every once in a while if they're not getting the hint, but don't spam it).
Once you've defeated the bad dudes who were invading your base, there's usually a station with repair tools somewhere nearby. You can use it to swap out one of your weapons for a standard repair tool to fix your generator. Doing that and then using an inventory station to switch back to technician is usually faster than killing yourself and respawning, since the technician's repair tool is only marginally faster than the standard one.