Searching in internet I found this page:
I have a similar problem. Iām trying to modify the structure of the .edmx file adding a complexType but this cause that throw a InvalidOperationException . I thought that creating a scope this problem would be avoided but was not the case. This is a piece of code I'm using:
public void AddComplexTypeToConceptualModel(XElement document, XElement entityType)
{
XElement lastEntityType = document.Descendants(XName.Get("EntityType", "http://schemas.microsoft.com/ado/2008/09/edm")).LastOrDefault();
if (lastEntityType != null)
{
using (EntityDesignerChangeScope scope = Context.CreateChangeScope("Create ComplexType in Conceptual Model"))
{
lastEntityType.AddAfterSelf(CreateComplexType(entityType));
// Commit the changes.
scope.Complete();
}
}
}
When I run the code show above I receive an InvalidOperationException: A property extention cannot edit an item in an Entity Framework namespace
Another possibility that I am evaluating is use ModelTransformExtension class to make changes on the context.CurrentDocument.
You know any way to do this without this exception occurs? Any help or suggestions will be welcomed.
Thanks in advance
Octavio