src/Misc/EFTools/EntityDesign/VisualStudio/ModelWizard/engine/updatefromdatabaseengine.cs
// <summary>
//     Will validate the passed in artifact and throw an exception if validation fails
//     TODO: figure out what to do with the actual errors (write to a log?)
// </summary>
Will validate the passed in artifact and throw an exception if validation fails
TODO: figure out what to do with the actual errors (write to a log?)
Will validate the passed in artifact and throw an exception if validation fails TODO : figure out what to do with the actual errors ( write to a log? )
[SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")]
        private static void ValidateArtifact(EntityDesignModelManager modelManager, EFArtifact artifact, WizardKind kind)
        {
            var errorsFound = false;
            Exception caughtException = null;
            try
            {
                VsUtils.EnsureProvider(artifact);
                var artifactSet = (EntityDesignArtifactSet)modelManager.GetArtifactSet(artifact.Uri);
                modelManager.ValidateAndCompileMappings(artifactSet, false); 
                var errors = artifactSet.GetAllErrorsForArtifact(artifact);
                if (errors != null
                    && errors.Count > 0)
                {
                    foreach (var error in errors)
                    {
                        if (error.IsError())
                        {
                            errorsFound = true;
                            break;
                        }
                    }
                }
            }
            catch (Exception e)
            {
                caughtException = e;
            }
            if (errorsFound || caughtException != null)
            {
                var message = string.Empty;
                if (kind == WizardKind.Generate)
                {
                    message = Resources.Extensibility_ExtensionMadeBadModel;
                }
                else if (kind == WizardKind.UpdateModel)
                {
                    message = Resources.Extensibility_ExtensionMadeBadModel_Update;
                }
                if (caughtException == null)
                {
                    throw new InvalidOperationException(message);
                }
                else
                {
                    throw new InvalidOperationException(message, caughtException);
                }
            }
        }
[ SuppressMessage ( " " , " " ) ] private static void ValidateArtifact ( EntityDesignModelManager modelManager , EFArtifact artifact , WizardKind kind ) { var errorsFound = false ; Exception caughtException = null ; try { VsUtils . EnsureProvider ( artifact ) ; var artifactSet = ( EntityDesignArtifactSet ) modelManager . GetArtifactSet ( artifact . Uri ) ; modelManager . ValidateAndCompileMappings ( artifactSet , false ) ; var errors = artifactSet . GetAllErrorsForArtifact ( artifact ) ; if ( errors != null && errors . Count > 0 ) { foreach ( var error in errors ) { if ( error . IsError ( ) ) { errorsFound = true ; break ; } } } } catch ( Exception e ) { caughtException = e ; } if ( errorsFound || caughtException != null ) { var message = string . Empty ; if ( kind == WizardKind . Generate ) { message = Resources . Extensibility_ExtensionMadeBadModel ; } else if ( kind == WizardKind . UpdateModel ) { message = Resources . Extensibility_ExtensionMadeBadModel_Update ; } if ( caughtException == null ) { throw new InvalidOperationException ( message ) ; } else { throw new InvalidOperationException ( message , caughtException ) ; } } }
Will validate the passed in artifact and throw an exception if validation fails
TODO: figure out what to do with the actual errors (write to a log?)
Will validate the passed in artifact and throw an exception if validation fails TODO : figure out what to do with the actual errors ( write to a log? )
// just run the runtime's validation
modelManager
EntityDesignModelManager
artifact
EFArtifact
kind
WizardKind