public override void Load(OpenedFile file, Stream stream)
        {
            Debug.Assert(file == this.PrimaryFile);

            EDMDesignerChangeWatcher.Init = true;

            // Load EDMX from stream
            XElement          edmxElement    = null;
            Action <XElement> readMoreAction = edmxElt => edmxElement = edmxElt;

            _edmView = new EDMView(stream, readMoreAction);

            // If EDMX is empty run EDM Wizard
            if (_edmView.EDM.IsEmpty)
            {
                edmxElement = null;
                EDMWizardWindow wizard = RunWizard(file, ProjectService.CurrentProject.RootNamespace);

                if (wizard.DialogResult == true)
                {
                    _edmView = new EDMView(wizard.EDMXDocument, readMoreAction);
                }
                else
                {
                    throw new WizardCancelledException();
                }
            }

            // Load or generate DesignerView and EntityTypeDesigners
            EntityTypeDesigner.Init = true;

            XElement designerViewsElement = null;

            if (edmxElement == null || (designerViewsElement = EDMXIO.ReadSection(edmxElement, EDMXIO.EDMXSection.DesignerViews)) == null)
            {
                designerViewsElement = DesignerIO.GenerateNewDesignerViewsFromCSDLView(_edmView);
            }

            if (edmxElement != null && designerViewsElement != null)
            {
                DesignerIO.Read(_edmView, designerViewsElement, entityType => new EntityTypeDesigner(entityType), complexType => new ComplexTypeDesigner(complexType));
            }

            EntityTypeDesigner.Init = false;

            // Call DoEvents, otherwise drawing associations can fail
            VisualHelper.DoEvents();

            // Gets the designer canvas
            _designerCanvas       = DesignerCanvas.GetDesignerCanvas(this, _edmView, _edmView.DesignerViews.FirstOrDefault());
            _scrollViewer.Content = _designerCanvas;

            // Register CSDL of EDMX in CSDL DatabaseTreeView
            CSDLDatabaseTreeViewAdditionalNode.Instance.CSDLViews.Add(_edmView.CSDL);

            EDMDesignerChangeWatcher.Init = false;
        }
        public override void Load(OpenedFile file, Stream stream)
        {
            Debug.Assert(file == this.PrimaryFile);

            EDMDesignerChangeWatcher.Init = true;

            // Load EDMX from stream
            XElement          edmxElement    = null;
            Action <XElement> readMoreAction = edmxElt => edmxElement = edmxElt;

            _edmView = new EDMView(stream, readMoreAction);

            // If EDMX is empty run EDM Wizard
            if (_edmView.EDM.IsEmpty)
            {
                edmxElement = null;

                string ns = String.Empty;
                if (ProjectService.CurrentProject == null)
                {
                    ns = ICSharpCode.Core.MessageService.ShowInputBox("EDMDesigner", "Enter NameSpace", "DefaultNamespace");
                }
                else
                {
                    ns = ProjectService.CurrentProject.RootNamespace;
                }

                EDMWizardWindow wizard = RunWizard(file, ns);

                if (wizard.DialogResult == true)
                {
                    _edmView = new EDMView(wizard.EDMXDocument, readMoreAction);
                }
                else
                {
                    throw new WizardCancelledException();
                }
            }

            // Load or generate DesignerView and EntityTypeDesigners
            EntityTypeDesigner.Init = true;

            XElement designerViewsElement = null;

            if (edmxElement == null || (designerViewsElement = EDMXIO.ReadSection(edmxElement, EDMXIO.EDMXSection.DesignerViews)) == null)
            {
                designerViewsElement = DesignerIO.GenerateNewDesignerViewsFromCSDLView(_edmView);
            }

            if (edmxElement != null && designerViewsElement != null)
            {
                DesignerIO.Read(_edmView, designerViewsElement, entityType => new EntityTypeDesigner(entityType), complexType => new ComplexTypeDesigner(complexType));
            }

            EntityTypeDesigner.Init = false;

            // Gets the designer canvas
            _designerCanvas       = DesignerCanvas.GetDesignerCanvas(this, _edmView, _edmView.DesignerViews.FirstOrDefault());
            _scrollViewer.Content = _designerCanvas;

            // Register CSDL of EDMX in CSDL DatabaseTreeView
            CSDLViews.Add(_edmView.CSDL);

            EDMDesignerChangeWatcher.Init = false;
        }