EF migration shows empty Up() Down() methods

后端 未结 17 2366
花落未央
花落未央 2020-12-25 09:56

I have a local database that is currently in it\'s second version and should now go to it\'s third version.

The code for the previous migrations was generated by ano

17条回答
  •  -上瘾入骨i
    2020-12-25 10:13

    I had to Update-Database with the latest migration before the empty one appending this parameter -TargetMigration:"{your-migration-name}".

    Probably it will tell you that there will be data loss from the next buggy one we tried. If you can afford it append -Force to it.

    Then I tried to add my new Add-Migration and it wasn't empty.

    Final thing that you may need to do if above is throwing exception is to go SQL Server Management Studio and delete the last Automatic migration and try to add it again.

提交回复
热议问题