Delete table from EF CodeFirst migration

c# ef-code-first ef-migrations entity-framework sql-server

Question

I want to delete one table in EF Code and then remove a column from it.

One migration file was created automatically after eliminating one column from the class file.

nonetheless, how to remove a table.

Which command must be fired? Do I also need to delete the following line from the context file in addition to the whole class file?

 public DbSet<TableClassName> TableClassNameSet { get; set; }

I use the command Add Migration 'TableClassName'.

So, how should a table be removed?

1
6
8/14/2016 5:46:00 AM

Popular Answer

You may rollback the previous migration if you just recently made the modifications. If not, just modify your models, and the modifications will be reflected in the next migration. Simply delete the appropriate row from a table to eliminate it.DbSet<MyClass> and EF will automatically add a DropTable to the migration if there are any references to that class in other areas of your model. You may remove the class if you are no longer utilising it for non-Entity Framework uses.

5
5/23/2017 12:08:09 PM


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