I have an XML document that looks like this:
I found a solution all thanks to your ideas. The general Idea is I changed the value of p1 to anything added my new attribute then returned p1 to its original value even before saving the XDocument.
XAttribute p1 = csdlDoc.Root.Attributes()
.First(a => a.IsNamespaceDeclaration && a.Name.LocalName == "p1");
p1.Value = "http://schemas.microsoft.com/ado/2009/02/edm/annotation/TEMP";
......
// the same update now works as there is only one xmlns
XNamespace annotation = "http://schemas.microsoft.com/ado/2009/02/edm/annotation";
var attrib = new XAttribute(annotation + "StoreGeneratedPattern", "Computed");
csdlProperty.Add(attrib);
p1.Value = "http://schemas.microsoft.com/ado/2009/02/edm/annotation/";
Another solution that worked is swapping the order or the declarations at the root node (declare p1 before annotation) like below:
In general both look like cheap solutions..