src/Misc/EFTools/EntityDesignModel/EntityDesignArtifact.cs
/// <summary>
///     This will do analysis to determine if a document should be opened
///     only in the XmlEditor.
/// </summary>
This will do analysis to determine if a document should be opened
only in the XmlEditor.
This will do analysis to determine if a document should be opened only in the XmlEditor .
internal void DetermineIfArtifactIsStructurallySafe()
        {
            if (DataServicesNodePresent)
            {
                _isStructurallySafe = false;
                return;
            }
            _isStructurallySafe = true;
            var artifactSet = (EntityDesignArtifactSet)ArtifactSet;
            EscherModelValidator.ValidateEscherModel(artifactSet, true);
            var shouldValidateMappings = artifactSet.ShouldDoRuntimeMappingValidation();
            new RuntimeMetadataValidator(ModelManager, SchemaVersion, DependencyResolver.Instance)
                .Validate(artifactSet);
            foreach (var ei in artifactSet.GetAllErrors())
            {
                if (EscherModelValidator.IsOpenInEditorError(ei)
                    || RuntimeMetadataValidator.IsOpenInEditorError(ei, this))
                {
                    _isStructurallySafe = false;
                }
            }
            if (_isStructurallySafe && IsXmlValid() == false)
            {
                _isStructurallySafe = false;
            }
            else if (DesignerInfo == null
                     || DesignerInfo.Diagrams == null)
            {
                _isStructurallySafe = false;
            }
            else if (ConceptualModel == null
                     || ConceptualModel.EntityContainerCount > 1)
            {
                _isStructurallySafe = false;
            }
            else if (MappingModel == null
                     || StorageModel == null)
            {
                _isStructurallySafe = false;
            }
             now we decide if we need to clear out the MSL errors from runtime validation above
            if (shouldValidateMappings == false && _isStructurallySafe)
            {
                artifactSet.ClearErrors(ErrorClass.Runtime_MSL);
                artifactSet.ClearErrors(ErrorClass.Runtime_ViewGen);
            }
        }
internal void DetermineIfArtifactIsStructurallySafe ( ) { if ( DataServicesNodePresent ) { _isStructurallySafe = false ; return ; } _isStructurallySafe = true ; var artifactSet = ( EntityDesignArtifactSet ) ArtifactSet ; EscherModelValidator . ValidateEscherModel ( artifactSet , true ) ; var shouldValidateMappings = artifactSet . ShouldDoRuntimeMappingValidation ( ) ; new RuntimeMetadataValidator ( ModelManager , SchemaVersion , DependencyResolver . Instance ) . Validate ( artifactSet ) ; foreach ( var ei in artifactSet . GetAllErrors ( ) ) { if ( EscherModelValidator . IsOpenInEditorError ( ei ) || RuntimeMetadataValidator . IsOpenInEditorError ( ei , this ) ) { _isStructurallySafe = false ; } } if ( _isStructurallySafe && IsXmlValid ( ) == false ) { _isStructurallySafe = false ; } else if ( DesignerInfo == null || DesignerInfo . Diagrams == null ) { _isStructurallySafe = false ; } else if ( ConceptualModel == null || ConceptualModel . EntityContainerCount > 1 ) { _isStructurallySafe = false ; } else if ( MappingModel == null || StorageModel == null ) { _isStructurallySafe = false ; } if ( shouldValidateMappings == false && _isStructurallySafe ) { artifactSet . ClearErrors ( ErrorClass . Runtime_MSL ) ; artifactSet . ClearErrors ( ErrorClass . Runtime_ViewGen ) ; } }
This will do analysis to determine if a document should be opened
only in the XmlEditor.
This will do analysis to determine if a document should be opened only in the XmlEditor .
// XSD prevents an EDMX from having both a DataServices node and a Runtime node // don't validate DataServices EDMX files // reset the value to true first - then determine if not safe below. // Do escher validation.  Doing this lets us determine if we want to keep MSL validation errors // in the artifact set, or just ignore them. // now do runtime validation.  Always pass true to do mapping validation since we need these errors to determine safe-mode // use the schema version of this artifact as the target Entity Framework version // scan all of the validation errors to see if we need to go into safe mode // the XML editor will "fix-up" parser errors for us, so we parse again just to be sure that there are none // if the edmx file is missing Designer or Diagrams element it's not designer safe // if the edmx file is missing ConceptualModel or it has multiple EntityContainers it's not designer safe // if the edmx file is missing MappingModel or StorageModel it's not designer safe // // now we decide if we need to clear out the MSL errors from runtime validation above //