How to edit previously applied migration without adding another migration in EF code first

ef-code-first ef-migrations entity-framework entity-framework-6

Question

I've already used the "haward" database structure in a migration.

public partial class CreateCourseCategoryTable : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "haward.CourseCategories",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        Name = c.String(),
                        Code = c.String(),
                    })
                .PrimaryKey(t => t.Id);
        }

        public override void Down()
        {
            DropTable("haward.CourseCategories");
        }
    }

utilizing this mapping

public class CourseCategoryMapping : EntityTypeConfiguration<CourseCategory>
    {
        public CourseCategoryMapping()
        {
            ToTable("CourseCategories", "haward");
        }
    }

Now that I want to switch the schema from "haward" to "tr," I don't want to add migration with it, therefore I thought of just modifying the Migration and Mapping source code directly.

public partial class CreateCourseCategoryTable : DbMigration
        {
            public override void Up()
            {
                CreateTable(
                    "tr.CourseCategories",
                    c => new
                        {
                            Id = c.Int(nullable: false, identity: true),
                            Name = c.String(),
                            Code = c.String(),
                        })
                    .PrimaryKey(t => t.Id);
            }

            public override void Down()
            {
                DropTable("tr.CourseCategories");
            }
        }


    public class CourseCategoryMapping : EntityTypeConfiguration<CourseCategory>
        {
            public CourseCategoryMapping()
            {
                ToTable("CourseCategories", "tr");
            }
        }

I created a blank database and ran the update-database command, but it indicated that I still had pending changes.

I used the add-migration command to determine which modifications are those. and it appears that even without the migrations table, it still recognizes my edits (from the "haward" to the "tr" schema).

Where are the changes to the model saved? and how can you modify the source code directly and apply the migration again? I'm aware that's not a good idea—migration is for that. However, I don't want to tarnish my history with those few alterations, especially because I'm still in the early stages of development.

1
8
2/22/2014 8:19:09 AM

Popular Answer

ZZZ_tmp
20
12/30/2016 8:08:54 AM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow