![]() So in that case, you have to use the 0 (ordinal) value. If you want to rollback all migrations and start over, you can use: Update-Database -Target:0Ġ, above, would rollback even the FIRST migration ( this is a destructive command-be sure you know what you're doing before you use it!)-something you cannot do if you use the syntax above that requires the name of the target migration (the name of the 0th migration doesn't exist before a migration is applied!). Thus, if you use GET-MIGRATIONS and you find that you have A, B, C, D, and E, then using this command will rollback E and D to get you to C: Update-Database -TargetMigration:"C"Īlso, unless anyone can comment to the contrary, I noticed that you can use an ordinal value and the short -Target switch (thus, -Target is the same as -TargetMigration). ![]() What you are doing above is saying that you want to rollback all migrations UNTIL you're left with the migration specified. I want to add some clarification to this thread: Update-Database -TargetMigration:"name_of_migration" This.Property(t => t.SomeText).HasColumnName("SomeText") This.Property(t => t.SomeId).HasColumnName("SomeId") Public class MyTableMap : EntityTypeConfiguration Result of add-migration: namespace MyProject.Migrations I am assuming that the scaffolding doesn't know where to look for the new class… or is this by convention that all model classes are just expected to be in the project? This is my command: add-migration "1.2" -verbose -ProjectName "MyEFproject" ![]() I think something is going wrong when scaffolding the previous migrations… It's like it can't find the new Code-First classes I have added. If I run my application now, the third migration is also added but obviously the new table is not being created because it's not in the Up() method. When I look in the database there is a _migrationHistory available with the previous 2 migrations. Infortunately I get an empty migration Up() and Down() method. So now I added 1 new class in the same manner as those previous classes and then run the add-migration command in the Package Manager Console. In my model there are around 30 classes, and inside the model folder there is a mapping folder and it contains the mappings for those 30 classes. The code for the previous migrations was generated by another programmer so I am assuming I am doing something wrong here. I have a local database that is currently in it's second version and should now go to it's third version.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |