Ejemplo n.º 1
0
        private StoreItemCollection ValidateStoreModel(EntityDesignArtifact designArtifact)
        {
            Debug.Assert(designArtifact != null, "designArtifact != null");

            var artifactSet = designArtifact.ArtifactSet;

            if (designArtifact.StorageModel == null)
            {
                artifactSet.AddError(
                    new ErrorInfo(
                        ErrorInfo.Severity.ERROR,
                        Resources.ErrorValidatingArtifact_StorageModelMissing,
                        designArtifact,
                        ErrorCodes.ErrorValidatingArtifact_StorageModelMissing,
                        ErrorClass.Runtime_SSDL));

                return(null);
            }

            if (SchemaManager.GetSchemaVersion(designArtifact.StorageModel.XElement.Name.Namespace) > _targetEntityFrameworkRuntimeVersion)
            {
                // the xml namespace of the ssdl Schema node is for a later version of the runtime than we are validating against
                artifactSet.AddError(
                    new ErrorInfo(
                        ErrorInfo.Severity.ERROR,
                        Resources.ErrorValidatingArtifact_InvalidSSDLNamespaceForTargetFrameworkVersion,
                        designArtifact.StorageModel,
                        ErrorCodes.ErrorValidatingArtifact_InvalidSSDLNamespaceForTargetFrameworkVersion,
                        ErrorClass.Runtime_CSDL));

                return(null);
            }

            using (var reader = CreateXmlReader(designArtifact, designArtifact.StorageModel.XElement))
            {
                IList <EdmSchemaError> storeErrors;
                var storeItemCollection =
                    StoreItemCollection.Create(new[] { reader }, null, _dependencyResolver, out storeErrors);

                Debug.Assert(storeErrors != null);

                // also process cached errors and warnings (if any) from reverse engineering db
                ProcessErrors(
                    storeErrors.Concat(designArtifact.GetModelGenErrors() ?? Enumerable.Empty <EdmSchemaError>()),
                    designArtifact, ErrorClass.Runtime_SSDL);

                return(storeItemCollection);
            }
        }
        private StoreItemCollection ValidateStoreModel(EntityDesignArtifact designArtifact)
        {
            Debug.Assert(designArtifact != null, "designArtifact != null");

            var artifactSet = designArtifact.ArtifactSet;

            if (designArtifact.StorageModel == null)
            {
                artifactSet.AddError(
                    new ErrorInfo(
                        ErrorInfo.Severity.ERROR,
                        Resources.ErrorValidatingArtifact_StorageModelMissing,
                        designArtifact,
                        ErrorCodes.ErrorValidatingArtifact_StorageModelMissing,
                        ErrorClass.Runtime_SSDL));

                return null;
            }

            if (SchemaManager.GetSchemaVersion(designArtifact.StorageModel.XElement.Name.Namespace) > _targetEntityFrameworkRuntimeVersion)
            {
                // the xml namespace of the ssdl Schema node is for a later version of the runtime than we are validating against
                artifactSet.AddError(
                    new ErrorInfo(
                        ErrorInfo.Severity.ERROR,
                        Resources.ErrorValidatingArtifact_InvalidSSDLNamespaceForTargetFrameworkVersion,
                        designArtifact.StorageModel,
                        ErrorCodes.ErrorValidatingArtifact_InvalidSSDLNamespaceForTargetFrameworkVersion,
                        ErrorClass.Runtime_CSDL));

                return null;
            }

            using (var reader = CreateXmlReader(designArtifact, designArtifact.StorageModel.XElement))
            {
                IList<EdmSchemaError> storeErrors;
                var storeItemCollection =
                    StoreItemCollection.Create(new[] { reader }, null, _dependencyResolver, out storeErrors);

                Debug.Assert(storeErrors != null);

                // also process cached errors and warnings (if any) from reverse engineering db
                ProcessErrors(
                    storeErrors.Concat(designArtifact.GetModelGenErrors() ?? Enumerable.Empty<EdmSchemaError>()),
                    designArtifact, ErrorClass.Runtime_SSDL);

                return storeItemCollection;
            }
        }