internal void ModelFirstVerifierRunner(string csdlArtifactName, Version versionOfCsdl) { UITestRunner.Execute(TestContext.TestName, () => { var workflowFilePath = Path.Combine( VsUtils.GetVisualStudioInstallDir(), @"Extensions\Microsoft\Entity Framework Tools\DBGen\TablePerTypeStrategy.xaml"); EdmItemCollection edmItemCollection; using ( var csdlStream = TestUtils.GetEmbeddedResourceStream("EFDesigner.InProcTests.TestData." + csdlArtifactName + ".csdl")) { edmItemCollection = new EdmItemCollection(new[] { XmlReader.Create(csdlStream) }); } var testName = "ModelFirstVerifier_" + csdlArtifactName; TestPipeline( testName, edmItemCollection, workflowFilePath, versionOfCsdl, args => { // Aggregate the inputs and outputs var ssdlOutput = (string)args.Outputs[EdmConstants.ssdlOutputName]; var mslOutput = (string)args.Outputs[EdmConstants.mslOutputName]; var storeItemCollection = EdmExtension.CreateAndValidateStoreItemCollection( ssdlOutput, EntityFrameworkVersion.Version2, new LegacyDbProviderServicesResolver(), false); // First we need to validate the MSL (the SSDL has already been validated // otherwise the SSDL to DDL step would have failed) new StorageMappingItemCollection( edmItemCollection, storeItemCollection, new[] { XmlReader.Create(new StringReader(mslOutput)) }); var sb = new StringBuilder( new XElement( "StorageAndMappings", XElement.Parse(ssdlOutput, LoadOptions.PreserveWhitespace), new XText(Environment.NewLine + Environment.NewLine), new XComment("Finished generating the storage layer. Here are the mappings:"), new XText(Environment.NewLine + Environment.NewLine), XElement.Parse(mslOutput, LoadOptions.PreserveWhitespace)).ToString()); // Enable the following when we can get the template to run InProc sb.AppendLine().AppendLine().AppendLine("The generated DDL:"); sb.AppendLine(ScrubDdl((string)args.Outputs[EdmConstants.ddlOutputName])); return(sb.ToString()); }); }); }
protected override void Execute(NativeActivityContext context) { var edmItemCollection = CsdlInput.Get(context); if (edmItemCollection == null) { throw new InvalidOperationException(Resources.ErrorCouldNotFindCSDL); } var symbolResolver = context.GetExtension <SymbolResolver>(); var edmParameterBag = symbolResolver[typeof(EdmParameterBag).Name] as EdmParameterBag; if (edmParameterBag == null) { throw new InvalidOperationException(Resources.ErrorNoEdmParameterBag); } // Find the TargetVersion parameter var targetFrameworkVersion = edmParameterBag.GetParameter <Version>(EdmParameterBag.ParameterName.TargetVersion); if (targetFrameworkVersion == null) { throw new InvalidOperationException( String.Format( CultureInfo.CurrentCulture, Resources.ErrorNoParameterDefined, EdmParameterBag.ParameterName.TargetVersion.ToString())); } // Validate the TargetVersion parameter if (false == EntityFrameworkVersion.IsValidVersion(targetFrameworkVersion)) { throw new InvalidOperationException( String.Format(CultureInfo.CurrentCulture, Resources.ErrorNonValidTargetVersion, targetFrameworkVersion)); } // Construct the Code View inputs in a dictionary var inputs = new Dictionary <string, object> { { EdmConstants.csdlInputName, edmItemCollection } }; // Process the SSDL and MSL code views, feeding in the CSDL var ssdl = ProcessOutputGenerator <string>(OutputGeneratorType.Get(context), context, inputs); var msl = ProcessOutputGenerator <string>(MslOutputGeneratorType.Get(context), context, inputs); // Validate the SSDL, but catch any naming errors and throw a friendlier one var ssdlCollection = EdmExtension.CreateAndValidateStoreItemCollection( ssdl, targetFrameworkVersion, DependencyResolver.Instance, true); #if DEBUG // Validate the MSL in Debug mode IList <EdmSchemaError> mslErrors; EdmExtension.CreateStorageMappingItemCollection( edmItemCollection, ssdlCollection, msl, out mslErrors); if (mslErrors != null && mslErrors.Count > 0) { var errorSb = new StringBuilder(); errorSb.AppendLine("Encountered the following errors while validating the MSL:"); foreach (var error in mslErrors) { errorSb.AppendLine(error.Message); } Debug.Fail(errorSb.ToString()); } #endif // We are done processing, save off all the outputs for the next stage SsdlOutput.Set(context, ssdl); MslOutput.Set(context, msl); }