Code first migrations - how to display pending model changes?

前端 未结 2 361
情话喂你
情话喂你 2020-12-29 21:32

I\'m using code first migrations. Is there a way to display pending model changes in package manager console before I scaffold a new migration?

2条回答
  •  感动是毒
    2020-12-29 22:29

    There is no way that I know of to view pending changes in the model before scaffolding the migration, but I can't think of a reason not to scaffold the migration using Add-Migration so that the pending changes can be viewed in the migration file. There is no need to apply those changes to the database and the scaffolded migration can always be deleted.

    Once the migration is scaffolded, if you use Update-Database -Script entity framework generates a SQL script rather than executing the changes directly.

    You can get help on the EntityFramework in the package manager using get-help EntityFramework

    And you can get help on the Update-Database command using the following:

    get-help Update-Database

    get-help Update-Database -detailed

    get-help Update-Database -full

提交回复
热议问题