/// <summary> /// Gets an empty database on the test server of the appropriate DBMS /// </summary> /// <param name="type">The DBMS you want a server of (a valid connection string must exist in TestDatabases.txt)</param> /// <param name="dbnName">null for default test database name (recommended unless you are testing moving data from one database to another on the same test server)</param> /// <param name="server"></param> /// <param name="database"></param> /// <param name="justDropTablesIfPossible">Determines behaviour when the test database already exists. False to drop and recreate it. True to just drop tables (faster)</param> /// <returns></returns> protected DiscoveredDatabase GetCleanedServer(DatabaseType type, string dbnName, out DiscoveredServer server, out DiscoveredDatabase database, bool justDropTablesIfPossible = false) { switch (type) { case DatabaseType.MicrosoftSQLServer: server = new DiscoveredServer(DiscoveredServerICanCreateRandomDatabasesAndTablesOn.Builder); break; case DatabaseType.MySql: server = _discoveredMySqlServer == null ? null : new DiscoveredServer(_discoveredMySqlServer.Builder); break; case DatabaseType.Oracle: server = _discoveredOracleServer == null ? null : new DiscoveredServer(_discoveredOracleServer.Builder); break; default: throw new ArgumentOutOfRangeException("type"); } if (server == null) { Assert.Inconclusive(); } //the microsoft one should exist! others are optional if (!server.Exists() && type != DatabaseType.MicrosoftSQLServer) { Assert.Inconclusive(); } server.TestConnection(); database = server.ExpectDatabase(dbnName); if (justDropTablesIfPossible && database.Exists()) { foreach (var t in database.DiscoverTables(true)) { t.Drop(); } foreach (var t in database.DiscoverTableValuedFunctions()) { t.Drop(); } } else { database.Create(true); } server.ChangeDatabase(dbnName); Assert.IsTrue(database.Exists()); return(database); }
private void CreateCohortDatabase() { _cohortDatabase = DiscoveredServerICanCreateRandomDatabasesAndTablesOn.ExpectDatabase(CohortDatabaseName); if (_cohortDatabase.Exists()) { DeleteTables(_cohortDatabase); } else { _cohortDatabase.Create(); } string sql = string.Format(@" CREATE TABLE [dbo].[Cohort]( [PrivateID] [varchar](10) NOT NULL, [ReleaseID] [varchar](10) NULL, [cohortDefinition_id] [int] NOT NULL, CONSTRAINT [PK_Cohort] PRIMARY KEY CLUSTERED ( [PrivateID] ASC, [cohortDefinition_id] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] GO CREATE TABLE [dbo].[CohortDefinition]( [id] [int] IDENTITY(1,1) NOT NULL, [projectNumber] [int] NOT NULL, [version] [int] NOT NULL, [description] [varchar](4000) NOT NULL, [dtCreated] [date] NOT NULL, CONSTRAINT [PK_CohortDefinition] PRIMARY KEY NONCLUSTERED ( [id] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] GO ALTER TABLE [dbo].[CohortDefinition] ADD CONSTRAINT [DF_CohortDefinition_dtCreated] DEFAULT (getdate()) FOR [dtCreated] GO ALTER TABLE [dbo].[Cohort] WITH CHECK ADD CONSTRAINT [FK_Cohort_CohortDefinition] FOREIGN KEY([cohortDefinition_id]) REFERENCES [dbo].[CohortDefinition] ([id]) GO ALTER TABLE [dbo].[Cohort] CHECK CONSTRAINT [FK_Cohort_CohortDefinition] GO "); using (var con = _cohortDatabase.Server.GetConnection()) { con.Open(); UsefulStuff.ExecuteBatchNonQuery(sql, con, timeout: 15); con.Close(); } }
private DataTableUploadDestination PrepareDestination(IDataLoadEventListener listener, DataTable toProcess) { //see if the user has entered an extraction server/database if (TargetDatabaseServer == null) { throw new Exception("TargetDatabaseServer (the place you want to extract the project data to) property has not been set!"); } try { if (!_destinationDatabase.Exists()) { _destinationDatabase.Create(); } if (_request is ExtractGlobalsCommand) { return(null); } var tblName = _toProcess.TableName; //See if table already exists on the server (likely to cause problems including duplication, schema changes in configuration etc) if (_destinationDatabase.ExpectTable(tblName).Exists()) { listener.OnNotify(this, new NotifyEventArgs(ProgressEventType.Warning, "A table called " + tblName + " already exists on server " + TargetDatabaseServer + ", data load might crash if it is populated and/or has an incompatible schema")); } else { _tableDidNotExistAtStartOfLoad = true; } } catch (Exception e) { //Probably the database didn't exist or the credentials were wrong or something listener.OnNotify(this, new NotifyEventArgs(ProgressEventType.Error, "Failed to inspect destination for already existing datatables", e)); } _destination = new DataTableUploadDestination(); PrimeDestinationTypesBasedOnCatalogueTypes(toProcess); _destination.AllowResizingColumnsAtUploadTime = true; _destination.AlterTimeout = AlterTimeout; _destination.PreInitialize(_destinationDatabase, listener); return(_destination); }
public void CreateStaging(DiscoveredServer liveServer) { _stagingDatabase = liveServer.ExpectDatabase(GetDatabaseName(null, LoadBubble.Staging)); if (!_stagingDatabase.Exists()) { _stagingDatabase.Create(); } //get rid of any old data from previous load foreach (var t in _stagingDatabase.DiscoverTables(false)) { t.Truncate(); } }
/// <summary> /// Sets up the databases <see cref="From"/> and <see cref="To"/> on the test database server of the given /// <paramref name="dbType"/>. This method is automatically called with <see cref="DatabaseType.MicrosoftSQLServer"/> /// in <see cref="OneTimeSetUp()"/> (nunit automatically fires it). /// </summary> /// <param name="dbType"></param> protected void SetupFromTo(DatabaseType dbType) { To = GetCleanedServer(dbType); From = To.Server.ExpectDatabase(To.GetRuntimeName() + Suffix); // ensure the test staging and live databases are empty if (!From.Exists()) { From.Create(); } else { DeleteTables(From); } }
private bool CreateDatabaseIfNotExists(DiscoveredDatabase db) { if (db == null) { MessageBox.Show("Choose a database"); return(false); } if (db.Exists()) { return(true); } if (MessageBox.Show("Create database '" + db + "'", "Create", MessageBoxButtons.YesNo) != DialogResult.Yes) { return(false); } db.Create(); return(true); }
/// <summary> /// Creates the <see cref="BulkDataTable"/> in the <see cref="BulkDataDatabase"/> and uploads test data. Use <see cref="ImportAsCatalogue"/> to get /// rdmp metadata objects pointing at the table. /// </summary> public void SetupTestData() { //make sure database exists if (!BulkDataDatabase.Exists()) { BulkDataDatabase.Create(); } //generate some people var people = new PersonCollection(); people.GeneratePeople(5000, r); //generate the test data var dt = _dataGenerator.GetDataTable(people, ExpectedNumberOfRowsInTestData); var tbl = BulkDataDatabase.ExpectTable(BulkDataTable); if (tbl.Exists()) { tbl.Drop(); } //create the table but make sure the chi is a primary key and the correct data type and that we have a sensible primary key Table = BulkDataDatabase.CreateTable(BulkDataTable, dt, new DatabaseColumnRequest[] { new DatabaseColumnRequest("chi", new DatabaseTypeRequest(typeof(string), 10)) { IsPrimaryKey = true }, new DatabaseColumnRequest("dtCreated", new DatabaseTypeRequest(typeof(DateTime))) { IsPrimaryKey = true }, new DatabaseColumnRequest("hb_extract", new DatabaseTypeRequest(typeof(string), 1)) { IsPrimaryKey = true } }); }
public void BeforeEachTest() { _catalogue = CatalogueRepository.GetAllObjects <Catalogue>("WHERE Name='BackfillSqlHelperTests'").SingleOrDefault(); if (_catalogue != null) { // Previous test run has not exited cleanly foreach (var ti in _catalogue.GetTableInfoList(false)) { ti.DeleteInDatabase(); } _catalogue.DeleteInDatabase(); } _stagingDatabase = DiscoveredServerICanCreateRandomDatabasesAndTablesOn.ExpectDatabase(DatabaseName + "_STAGING"); _liveDatabase = DiscoveredServerICanCreateRandomDatabasesAndTablesOn.ExpectDatabase(DatabaseName); // ensure the test staging and live databases are empty _stagingDatabase.Create(true); _liveDatabase.Create(true); CleanCatalogueDatabase(); }
private void CopyCohortToDataServer(IDataLoadEventListener listener, GracefulCancellationToken cancellationToken) { DataTable cohortDataTable = null; SetServer(); listener.OnNotify(this, new NotifyEventArgs(ProgressEventType.Information, "About to wait for Semaphore OneCrossServerExtractionAtATime to become available")); OneCrossServerExtractionAtATime.WaitOne(-1); listener.OnNotify(this, new NotifyEventArgs(ProgressEventType.Information, "Captured Semaphore OneCrossServerExtractionAtATime")); try { IExtractableCohort cohort = Request.ExtractableCohort; cohortDataTable = cohort.FetchEntireCohort(); } catch (Exception e) { throw new Exception("An error occurred while trying to download the cohort from the Cohort server (in preparation for transfering it to the data server for linkage and extraction)", e); } //make sure tempdb exists (this covers you for servers where it doesn't exist e.g. mysql or when user has specified a different database name) if (!_tempDb.Exists()) { if (CreateAndDestroyTemporaryDatabaseIfNotExists) { _tempDb.Create(); _hadToCreate = true; } else { throw new Exception("Database '" + _tempDb + "' did not exist on server '" + _server + "' and CreateAndDestroyTemporaryDatabaseIfNotExists was false"); } } else { _hadToCreate = false; } var tbl = _tempDb.ExpectTable(cohortDataTable.TableName); if (tbl.Exists()) { listener.OnNotify(this, new NotifyEventArgs(ProgressEventType.Warning, "Found existing table called '" + tbl + "' in '" + _tempDb + "'")); if (DropExistingCohortTableIfExists) { listener.OnNotify(this, new NotifyEventArgs(ProgressEventType.Warning, "About to drop existing table '" + tbl + "'")); try { tbl.Drop(); listener.OnNotify(this, new NotifyEventArgs(ProgressEventType.Warning, "Dropped existing table '" + tbl + "'")); } catch (Exception ex) { listener.OnNotify(this, new NotifyEventArgs(ProgressEventType.Warning, "Warning dropping '" + tbl + "' failed", ex)); } } else { listener.OnNotify(this, new NotifyEventArgs(ProgressEventType.Warning, "'" + _tempDb + "' contains a table called '" + tbl + "' and DropExistingCohortTableIfExists is false")); } } var destination = new DataTableUploadDestination(); destination.PreInitialize(_tempDb, listener); destination.ProcessPipelineData(cohortDataTable, listener, cancellationToken); destination.Dispose(listener, null); if (!tbl.Exists()) { throw new Exception("Table '" + tbl + "' did not exist despite DataTableUploadDestination completing Successfully!"); } tablesToCleanup.Add(tbl); //table will now be in tempdb _haveCopiedCohortAndAdjustedSql = true; }
internal void Create(DiscoveredDatabase db, ICheckNotifier notifier, PlatformDatabaseCreationOptions options) { if (db.Exists()) { if (options.DropDatabases) { db.Drop(); } else { throw new Exception("Database " + db.GetRuntimeName() + " already exists and allowDrop option was not specified"); } } notifier.OnCheckPerformed(new CheckEventArgs("About to create " + db.GetRuntimeName(), CheckResult.Success)); //create a new database for the datasets db.Create(); notifier.OnCheckPerformed(new CheckEventArgs("Succesfully created " + db.GetRuntimeName(), CheckResult.Success)); //fixed seed so everyone gets the same datasets var r = new Random(options.Seed); notifier.OnCheckPerformed(new CheckEventArgs("Generating people", CheckResult.Success)); //people var people = new PersonCollection(); people.GeneratePeople(options.NumberOfPeople, r); //datasets var biochem = ImportCatalogue(Create <Biochemistry>(db, people, r, notifier, options.NumberOfRowsPerDataset, "chi", "Healthboard", "SampleDate", "TestCode")); var demography = ImportCatalogue(Create <Demography>(db, people, r, notifier, options.NumberOfRowsPerDataset, "chi", "dtCreated", "hb_extract")); var prescribing = ImportCatalogue(Create <Prescribing>(db, people, r, notifier, options.NumberOfRowsPerDataset, "chi", "PrescribedDate", "Name")); //<- this is slooo! var admissions = ImportCatalogue(Create <HospitalAdmissions>(db, people, r, notifier, options.NumberOfRowsPerDataset, "chi", "AdmissionDate")); var carotid = Create <CarotidArteryScan>(db, people, r, notifier, options.NumberOfRowsPerDataset, "RECORD_NUMBER"); //the following should not be extractable ForExtractionInformations(demography, e => e.DeleteInDatabase(), "chi_num_of_curr_record", "surname", "forename", "current_address_L1", "current_address_L2", "current_address_L3", "current_address_L4", "birth_surname", "previous_surname", "midname", "alt_forename", "other_initials", "previous_address_L1", "previous_address_L2", "previous_address_L3", "previous_address_L4", "previous_postcode", "date_address_changed", "adr", "previous_gp_accept_date", "hic_dataLoadRunID"); //the following should be special approval only ForExtractionInformations(demography, e => { e.ExtractionCategory = ExtractionCategory.SpecialApprovalRequired; e.SaveToDatabase(); }, "current_postcode", "current_gp", "previous_gp", "date_of_birth"); CreateAdmissionsViews(db); var vConditions = ImportCatalogue(db.ExpectTable("vConditions")); var vOperations = ImportCatalogue(db.ExpectTable("vOperations")); CreateGraph(biochem, "Test Codes", "TestCode", false, null); CreateGraph(biochem, "Test Codes By Date", "SampleDate", true, "TestCode"); CreateFilter(biochem, "Creatinine", "TestCode", "TestCode like '%CRE%'", @"Serum creatinine is a blood measurement. It is an indicator of renal health."); CreateFilter(biochem, "Test Code", "TestCode", "TestCode like @code", "Filters any test code set"); CreateExtractionInformation(demography, "Age", "date_of_birth", "FLOOR(DATEDIFF(DAY, date_of_birth, GETDATE()) / 365.25) As Age"); var fAge = CreateFilter(demography, "Older at least x years", "Age", "FLOOR(DATEDIFF(DAY, date_of_birth, GETDATE()) / 365.25) >= @age", "Patients age is greater than or equal to the provided @age"); SetParameter(fAge, "@age", "int", "16"); CreateGraph(demography, "Patient Ages", "Age", false, null); CreateGraph(prescribing, "Approved Name", "ApprovedName", false, null); CreateGraph(prescribing, "Approved Name Over Time", "PrescribedDate", true, "ApprovedName"); CreateGraph(prescribing, "Bnf", "FormattedBnfCode", false, null); CreateGraph(prescribing, "Bnf Over Time", "PrescribedDate", true, "FormattedBnfCode"); CreateFilter( CreateGraph(vConditions, "Conditions frequency", "Field", false, "Condition"), "Common Conditions Only", @"(Condition in (select top 40 Condition from vConditions c WHERE Condition <> 'NULL' AND Condition <> 'Nul' group by Condition order by count(*) desc))"); CreateFilter( CreateGraph(vOperations, "Operation frequency", "Field", false, "Operation"), "Common Operation Only", @"(Operation in (select top 40 Operation from vOperations c WHERE Operation <> 'NULL' AND Operation <> 'Nul' group by Operation order by count(*) desc))"); //group these all into the same folder admissions.Folder = new CatalogueFolder(admissions, @"\admissions"); admissions.SaveToDatabase(); vConditions.Folder = new CatalogueFolder(vConditions, @"\admissions"); vConditions.SaveToDatabase(); vOperations.Folder = new CatalogueFolder(vOperations, @"\admissions"); vOperations.SaveToDatabase(); //Create cohort store database var wizard = new CreateNewCohortDatabaseWizard(db, _repos.CatalogueRepository, _repos.DataExportRepository, false); var externalCohortTable = wizard.CreateDatabase(new PrivateIdentifierPrototype("chi", "varchar(10)"), new ThrowImmediatelyCheckNotifier()); //Find the pipeline for committing cohorts var cohortCreationPipeline = _repos.CatalogueRepository.GetAllObjects <Pipeline>().FirstOrDefault(p => p?.Source?.Class == typeof(CohortIdentificationConfigurationSource).FullName); if (cohortCreationPipeline == null) { throw new Exception("Could not find a cohort committing pipeline"); } //A cohort creation query var f = CreateFilter(vConditions, "Lung Cancer Condition", "Condition", "Condition like 'C349'", "ICD-10-CM Diagnosis Code C34.9 Malignant neoplasm of unspecified part of bronchus or lung"); var cic = CreateCohortIdentificationConfiguration((ExtractionFilter)f); var cohort = CommitCohortToNewProject(cic, externalCohortTable, cohortCreationPipeline, "Lung Cancer Project", "P1 Lung Cancer Patients", 123, out Project project); var cohortTable = cohort.ExternalCohortTable.DiscoverCohortTable(); using (var con = cohortTable.Database.Server.GetConnection()) { con.Open(); //delete half the records (so we can simulate cohort refresh) var cmd = cohortTable.Database.Server.GetCommand(string.Format("DELETE TOP (10) PERCENT from {0}", cohortTable.GetFullyQualifiedName()), con); cmd.ExecuteNonQuery(); } var ec1 = CreateExtractionConfiguration(project, cohort, "First Extraction (2016 - project 123)", true, notifier, biochem, prescribing, demography); var ec2 = CreateExtractionConfiguration(project, cohort, "Project 123 - 2017 Refresh", true, notifier, biochem, prescribing, demography, admissions); var ec3 = CreateExtractionConfiguration(project, cohort, "Project 123 - 2018 Refresh", true, notifier, biochem, prescribing, demography, admissions); ReleaseAllConfigurations(notifier, ec1, ec2, ec3); }
public ExternalCohortTable CreateDatabase(PrivateIdentifierPrototype privateIdentifierPrototype, ICheckNotifier notifier) { if (!_targetDatabase.Exists()) { notifier.OnCheckPerformed(new CheckEventArgs("Did not find database " + _targetDatabase + " on server so creating it", CheckResult.Success)); _targetDatabase.Create(); } try { var definitionTable = _targetDatabase.CreateTable("CohortDefinition", new[] { new DatabaseColumnRequest("id", new DatabaseTypeRequest(typeof(int))) { AllowNulls = false, IsAutoIncrement = true, IsPrimaryKey = true }, new DatabaseColumnRequest("projectNumber", new DatabaseTypeRequest(typeof(int))) { AllowNulls = false }, new DatabaseColumnRequest("version", new DatabaseTypeRequest(typeof(int))) { AllowNulls = false }, new DatabaseColumnRequest("description", new DatabaseTypeRequest(typeof(string), 3000)) { AllowNulls = false }, new DatabaseColumnRequest("dtCreated", new DatabaseTypeRequest(typeof(DateTime))) { AllowNulls = false, Default = MandatoryScalarFunctions.GetTodaysDate } }); var idColumn = definitionTable.DiscoverColumn("id"); var foreignKey = new DatabaseColumnRequest(_definitionTableForeignKeyField, new DatabaseTypeRequest(typeof(int)), false) { IsPrimaryKey = true }; var cohortTable = _targetDatabase.CreateTable("Cohort", new [] { new DatabaseColumnRequest(privateIdentifierPrototype.RuntimeName, privateIdentifierPrototype.DataType, false) { IsPrimaryKey = true }, new DatabaseColumnRequest(_releaseIdentifierFieldName, new DatabaseTypeRequest(typeof(string), 300)) { AllowNulls = AllowNullReleaseIdentifiers }, foreignKey } , //foreign key between id and cohortDefinition_id new Dictionary <DatabaseColumnRequest, DiscoveredColumn>() { { foreignKey, idColumn } }, true); notifier.OnCheckPerformed(new CheckEventArgs("About to create pointer to the source", CheckResult.Success)); var pointer = new ExternalCohortTable(_dataExportRepository, "TestExternalCohort", _targetDatabase.Server.DatabaseType) { DatabaseType = _targetDatabase.Server.DatabaseType, Server = _targetDatabase.Server.Name, Database = _targetDatabase.GetRuntimeName(), Username = _targetDatabase.Server.ExplicitUsernameIfAny, Password = _targetDatabase.Server.ExplicitPasswordIfAny, Name = _targetDatabase.GetRuntimeName(), TableName = cohortTable.GetRuntimeName(), PrivateIdentifierField = privateIdentifierPrototype.RuntimeName, ReleaseIdentifierField = _releaseIdentifierFieldName, DefinitionTableForeignKeyField = _definitionTableForeignKeyField, DefinitionTableName = definitionTable.GetRuntimeName() }; pointer.SaveToDatabase(); notifier.OnCheckPerformed(new CheckEventArgs("successfully created reference to cohort source in data export manager", CheckResult.Success)); notifier.OnCheckPerformed(new CheckEventArgs("About to run post creation checks", CheckResult.Success)); pointer.Check(notifier); notifier.OnCheckPerformed(new CheckEventArgs("Finished", CheckResult.Success)); return(pointer); } catch (Exception e) { notifier.OnCheckPerformed( new CheckEventArgs("Entire setup failed with exception (double click to find out why)", CheckResult.Fail, e)); return(null); } }
public void SetupExampleTables() { string sql = @"CREATE TABLE [dbo].[Tests]( [chi] [varchar](10) NULL, [Date] [datetime] NULL, [hb_extract] [varchar](1) NULL, [TestId] [int] NOT NULL, CONSTRAINT [PK_Tests] PRIMARY KEY CLUSTERED ( [TestId] ASC ) ) GO CREATE TABLE [dbo].[Results]( [TestId] [int] NOT NULL, [Measure] [varchar](10) NOT NULL, [Value] [int] NULL, CONSTRAINT [PK_Results] PRIMARY KEY CLUSTERED ( [TestId] ASC, [Measure] ASC ) ) GO ALTER TABLE [dbo].[Results] WITH CHECK ADD CONSTRAINT [FK_Results_Tests] FOREIGN KEY([TestId]) REFERENCES [dbo].[Tests] ([TestId]) GO"; var server = DiscoveredDatabaseICanCreateRandomTablesIn.Server; using (var con = server.GetConnection()) { con.Open(); UsefulStuff.ExecuteBatchNonQuery(sql, con); } var importer1 = new TableInfoImporter(CatalogueRepository, DiscoveredDatabaseICanCreateRandomTablesIn.ExpectTable("Tests")); var importer2 = new TableInfoImporter(CatalogueRepository, DiscoveredDatabaseICanCreateRandomTablesIn.ExpectTable("Results")); importer1.DoImport(out t1, out c1); importer2.DoImport(out t2, out c2); var engineer1 = new ForwardEngineerCatalogue(t1, c1, true); var engineer2 = new ForwardEngineerCatalogue(t2, c2, true); engineer1.ExecuteForwardEngineering(out cata1, out cataItems1, out eis1); engineer2.ExecuteForwardEngineering(out cata2, out cataItems2, out eis2); new JoinInfo(CatalogueRepository, c1.Single(e => e.GetRuntimeName().Equals("TestId")), c2.Single(e => e.GetRuntimeName().Equals("TestId")), ExtractionJoinType.Left, null); _anoTable = new ANOTable(CatalogueRepository, ANOStore_ExternalDatabaseServer, "ANOTes", "T"); _anoTable.NumberOfCharactersToUseInAnonymousRepresentation = 10; _anoTable.SaveToDatabase(); _anoTable.PushToANOServerAsNewTable("int", new ThrowImmediatelyCheckNotifier()); _comboCata = new Catalogue(CatalogueRepository, "Combo Catalogue"); //pk var ciTestId = new CatalogueItem(CatalogueRepository, _comboCata, "TestId"); var colTestId = c1.Single(c => c.GetRuntimeName().Equals("TestId")); ciTestId.ColumnInfo_ID = colTestId.ID; ciTestId.SaveToDatabase(); var eiTestId = new ExtractionInformation(CatalogueRepository, ciTestId, colTestId, colTestId.Name); //Measure var ciMeasure = new CatalogueItem(CatalogueRepository, _comboCata, "Measuree"); var colMeasure = c2.Single(c => c.GetRuntimeName().Equals("Measure")); ciMeasure.ColumnInfo_ID = colMeasure.ID; ciMeasure.SaveToDatabase(); var eiMeasure = new ExtractionInformation(CatalogueRepository, ciMeasure, colMeasure, colMeasure.Name); //Date var ciDate = new CatalogueItem(CatalogueRepository, _comboCata, "Dat"); var colDate = c1.Single(c => c.GetRuntimeName().Equals("Date")); ciDate.ColumnInfo_ID = colDate.ID; ciDate.SaveToDatabase(); var eiDate = new ExtractionInformation(CatalogueRepository, ciDate, colDate, colDate.Name); var destDatabaseName = TestDatabaseNames.GetConsistentName("ANOMigrationTwoTableTests"); _destinationDatabase = DiscoveredServerICanCreateRandomDatabasesAndTablesOn.ExpectDatabase(destDatabaseName); _destinationDatabase.Create(true); }