How can I stop Add-Migration checking my database has no pending migrations when using Code-Based migrations?

后端 未结 2 681
情话喂你
情话喂你 2020-12-19 07:07

I\'m investigating using Code-Based EF Migrations for a product that does not use EF. Everything generally works well, except that the command:

Add-         


        
相关标签:
2条回答
  • 2020-12-19 07:56

    Try commenting out your existing migrations (the ones that haven't been applied to the database created on .\SQLExpress) and re-running your app. That should populate the local database with the initial tables it needs.

    Once the local database has the correct structure you should be able to uncomment your migrations and then use update-database to bring the local one up to date. Then you'll be able to add a new migration.

    Also remember that there's a -connectionString parameter on the update-database command, so you can target your migrations at a specific server/db.

    0 讨论(0)
  • 2020-12-19 07:57

    I was seeing this error until I deleted from the Solution the original auto-generated migration code that the Package Manager had initially created.

    This would have been 201206260845338_DannyTest.cs in Danny's case.

    0 讨论(0)
提交回复
热议问题