问题
I'm using EF Code First 4.3 Migrations to update my database scheme. Now I have the following situation: table A needs to be removed, table B must be created and the data of table A must be copied (along with some other data) to table B. I do not have access to the DbContext
in the DbMigration
class, my question is how to implement this?
回答1:
In migration Up
method of your migration you can use Sql
method to define any SQL you need so if you use explicit migration you can put data migration code between creating Table B and removing Table A.
来源:https://stackoverflow.com/questions/11011695/entity-framework-4-3-migrations-move-existing-data