I just completed the Battle for Whiterun, and, as per my playstyle, I dismissed Lydia once that was done. When I dismissed her, the Legion (the side I fought for) started attacking her. What can I do to keep Lydia from dying and/or killing everyone?
After messing with various console commands, I figured out one way to solve it. I added Lydia to the Imperial Legion faction with the following console commands:
prid A2C94 addfac 2BF9A 1
I also had to use
resetai on everyone involved (I opted to just
kill a few of them) to make everyone put their weapons away.