【问题标题】:How to get the database update script from the last migration?如何从上次迁移中获取数据库更新脚本?
【发布时间】:2017-03-03 18:41:25
【问题描述】:

今天我以以下方式使用 EF 迁移:我使用

dotnet ef migrations add MigrationName

创建一个新的迁移,然后

dotnet ef database update

将上次更新应用到数据库。

现在,如果我只想生成最后一个迁移数据库更新脚本,有没有使用 dotnet ef 的方法?

我的意思是,显然在应用之前,工具链必须生成脚本,然后提交到数据库。

有没有办法只输出脚本而不应用到数据库?

【问题讨论】:

    标签: .net asp.net-core .net-core entity-framework-core entity-framework-migrations


    【解决方案1】:

    你可以使用

      dotnet ef migrations script -from (MigrationYouWant-1) -to MigrationYouWant
    

    创建 SQL 脚本(因此基本上所有内容都在“from”和“to”之间编写脚本,“from”不包括在内,“to”包括在内)。 您可以在此处找到有关该主题的更多信息:

    https://docs.microsoft.com/en-us/ef/core/miscellaneous/cli/dotnet

    【讨论】:

      猜你喜欢
      • 2012-12-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-06-02
      • 2017-03-04
      • 1970-01-01
      相关资源
      最近更新 更多