Esempio n. 1
0
        public void Should_detect_renamed_columns_when_swapped()
        {
            var modelBuilder = new DbModelBuilder();

            modelBuilder.Entity<TypeWithRenames>().Ignore(t => t.Bazz);

            var model1 = modelBuilder.Build(ProviderInfo);

            modelBuilder = new DbModelBuilder();

            modelBuilder.Entity<TypeWithRenames>().Property(t => t.Barz).HasColumnName("Bazz");

            var model2 = modelBuilder.Build(ProviderInfo);

            var operations
                = new EdmModelDiffer().Diff(model1.GetModel(), model2.GetModel());

            Assert.Equal(2, operations.Count());

            var renameColumnOperation = (RenameColumnOperation)operations.First();

            Assert.Equal("Barz", renameColumnOperation.Name);
            Assert.Equal("Bazz", renameColumnOperation.NewName);


            var addColumnOperation = (AddColumnOperation)operations.Last();

            Assert.Equal("Bazz1", addColumnOperation.Column.Name);
        }
Esempio n. 2
0
        public void Can_detect_changed_columns_when_renamed()
        {
            var modelBuilder = new DbModelBuilder();

            modelBuilder.Entity<MigrationsCustomer>();

            var model1 = modelBuilder.Build(ProviderInfo);

            modelBuilder
                .Entity<MigrationsCustomer>()
                .Property(c => c.FullName)
                .HasMaxLength(25)
                .HasColumnName("Foo");

            var model2 = modelBuilder.Build(ProviderInfo);

            var operations = new EdmModelDiffer().Diff(
                model1.GetModel(), model2.GetModel());

            Assert.Equal(2, operations.Count());

            var alterColumnOperation
                = (AlterColumnOperation)operations.Last();

            Assert.Equal("Foo", alterColumnOperation.Column.Name);

            var inverseAlterColumnOperation
                = (AlterColumnOperation)alterColumnOperation.Inverse;

            Assert.Equal("Foo", inverseAlterColumnOperation.Column.Name);
        }
Esempio n. 3
0
        public void Can_detect_simple_column_rename()
        {
            var modelBuilder = new DbModelBuilder();

            modelBuilder.Entity<MigrationsCustomer>();

            var model1 = modelBuilder.Build(ProviderInfo);

            modelBuilder
                .Entity<MigrationsCustomer>()
                .Property(p => p.Name)
                .HasColumnName("col_Name")
                .HasMaxLength(23);

            var model2 = modelBuilder.Build(ProviderInfo);

            var operations 
                = new EdmModelDiffer().Diff(model1.GetModel(), model2.GetModel());

            Assert.Equal(2, operations.Count());

            var renameColumnOperation = (RenameColumnOperation)operations.First();

            Assert.Equal("dbo.MigrationsCustomers", renameColumnOperation.Table);
            Assert.Equal("Name", renameColumnOperation.Name);
            Assert.Equal("col_Name", renameColumnOperation.NewName);
            
            var alterColumnOperation = (AlterColumnOperation)operations.Last();

            Assert.Equal("dbo.MigrationsCustomers", alterColumnOperation.Table);
            Assert.Equal("col_Name", alterColumnOperation.Column.Name);
            Assert.Equal(23, alterColumnOperation.Column.MaxLength);
        }