public void TestImporter()
        {
            const string streamPath = "Utilities.EF.Catalog.ssdl";

            var stream = Assembly.GetAssembly(GetType()).GetManifestResourceStream(streamPath);
            if (stream == null) Assert.IsTrue(false, "Cannot access ssdl embedded resource");
            var doc = XDocument.Load(XmlReader.Create(stream));

            //load entity framework into DSR
            var importer = new EntityFrameworkImporter();
            var schema = importer.ReadSsdl(doc);

            //we changed the length of one column
            ChangeMaxLength(doc);

            //load the new schema into DSR
            var schema2 = importer.ReadSsdl(doc);

            //use our comparer to create migration script
            var comparer = new DatabaseSchemaReader.Compare.CompareSchemas(schema, schema2);
            var sql = comparer.Execute();

            //(we could compare the EF model to the database
            //var schema3 =
            //    new DatabaseReader(
            //        @"data source=.\SQLEXPRESS;initial catalog=ProductCatalog;integrated security=True;multipleactiveresultsets=True;App=Test",
            //        SqlType.SqlServer).ReadAll();
            //var comparer2 = new DatabaseSchemaReader.Compare.CompareSchemas(schema, schema3);
            //var sql2 = comparer2.Execute();
            //Console.WriteLine(sql2);

            //assert
            Assert.IsTrue(sql.Contains("ALTER TABLE [dbo].[Categories] ALTER COLUMN [CategoryName] NVARCHAR (100)"), "Should generate alter table DDL");
        }
Exemplo n.º 2
0
        public void TestImporterV3()
        {
            //arrange

            //we have a EF v5 edmx (v3) as an embedded resource (this project is only EF 4)
            const string streamPath = "DatabaseSchemaReaderTest.Utilities.EF.CatalogV3.edmxv3";

            var stream = Assembly.GetAssembly(GetType()).GetManifestResourceStream(streamPath);

            if (stream == null)
            {
                Assert.IsTrue(false, "Cannot access edmxv3 embedded resource");
            }
            var doc = XDocument.Load(XmlReader.Create(stream));

            //load entity framework into DSR
            var importer = new EntityFrameworkImporter();
            var schema   = importer.ReadEdmx(doc);
            var schema2  = importer.ReadEdmx(doc);


            //act
            //use our comparer to create migration script
            var comparer = new DatabaseSchemaReader.Compare.CompareSchemas(schema, schema2);
            var sql      = comparer.Execute();


            //assert
            Assert.IsTrue(string.IsNullOrEmpty(sql), "Should have no differences");
        }
Exemplo n.º 3
0
        public void TestImporterV3()
        {
            //arrange

            //we have a EF v5 edmx (v3) as an embedded resource (this project is only EF 4)
            const string streamPath = "DatabaseSchemaReaderTest.Utilities.EF.CatalogV3.edmxv3";

            var stream = Assembly.GetAssembly(GetType()).GetManifestResourceStream(streamPath);
            if (stream == null) Assert.IsTrue(false, "Cannot access edmxv3 embedded resource");
            var doc = XDocument.Load(XmlReader.Create(stream));

            //load entity framework into DSR
            var importer = new EntityFrameworkImporter();
            var schema = importer.ReadEdmx(doc);
            var schema2 = importer.ReadEdmx(doc);


            //act
            //use our comparer to create migration script
            var comparer = new DatabaseSchemaReader.Compare.CompareSchemas(schema, schema2);
            var sql = comparer.Execute();


            //assert
            Assert.IsTrue(string.IsNullOrEmpty(sql), "Should have no differences");
        }
Exemplo n.º 4
0
        public void TestImporter()
        {
            const string streamPath = "Utilities.EF.Catalog.ssdl";

            var stream = Assembly.GetAssembly(GetType()).GetManifestResourceStream(streamPath);

            if (stream == null)
            {
                Assert.IsTrue(false, "Cannot access ssdl embedded resource");
            }
            var doc = XDocument.Load(XmlReader.Create(stream));

            //load entity framework into DSR
            var importer = new EntityFrameworkImporter();
            var schema   = importer.ReadSsdl(doc);

            //we changed the length of one column
            ChangeMaxLength(doc);

            //load the new schema into DSR
            var schema2 = importer.ReadSsdl(doc);

            //use our comparer to create migration script
            var comparer = new DatabaseSchemaReader.Compare.CompareSchemas(schema, schema2);
            var sql      = comparer.Execute();

            //(we could compare the EF model to the database
            //var schema3 =
            //    new DatabaseReader(
            //        @"data source=.\SQLEXPRESS;initial catalog=ProductCatalog;integrated security=True;multipleactiveresultsets=True;App=Test",
            //        SqlType.SqlServer).ReadAll();
            //var comparer2 = new DatabaseSchemaReader.Compare.CompareSchemas(schema, schema3);
            //var sql2 = comparer2.Execute();
            //Console.WriteLine(sql2);


            //assert
            Assert.IsTrue(sql.Contains("ALTER TABLE [dbo].[Categories] ALTER COLUMN [CategoryName] NVARCHAR (100)"), "Should generate alter table DDL");
        }