Last week I struggled again with (some of the most unpredictable
features within the the SharePoint code base:)
SPWebConfigModification. I just couldn't apply multiple mods at
once. So after few hours of trial and error I discovered that this
was the solution:
BAD CODE (will apply only 1 mod):
SPFarm.Local.Services.GetValue().ApplyWebConfigModifications();
webApplication.Update();
GOOD CODE (will apply all mods):
webApplication.Update();
SPFarm.Local.Services.GetValue().ApplyWebConfigModifications();
So the punchline is that the sequence of the method calling does
matter!