How do you rename an Entity Framework database after it has been created?

时间:2015-09-01 23:05:13

标签: entity-framework database-migration

I am using EF 6 code first. As part of the code-based migration, I would like to rename the existing database after applying all the pending migrations. Can this be done?

1 个答案:

答案 0 :(得分:1)

我不认为这可能(轻松?)可能(不会导致错误)

如果在迁移期间重命名数据库,它将无法将迁移写入migrationhistory表,因为连接字符串仍将指向旧数据库。

也许更好的选择是在系统中构建一些东西来重命名数据库并完全调整EF之外的所需配置。