Unable to generate an explicit migration in entity framework

后端 未结 28 1312
情书的邮戳
情书的邮戳 2020-12-12 23:31

I am adding a new migration but this message shows:

Unable to generate an explicit migration because the following explicit migrations are pending:

相关标签:
28条回答
  • Had the same issue and was able to solve with some hints from above answers:

    • In package manager console check the default project (point to the project with the migration configuration
    • Ensure the startup-proj has a web.config with a valid connectionstring ( or
    • Ensure the project with migrations has an app.config / web.config with a valid connectionstring
    • Check permissions in DB (for the user configured in you connectionstring)

    Use "update-database -verbose" in the package manager console to get more specific information where migrations tries to connect to. (Helped in my case to find out my startup proj was not set correctly...)

    0 讨论(0)
  • 2020-12-13 00:06

    This isn't going to be the answer for many people, but EF will chuck this error when it can't connect to the DB. If you're working from home like I am, make sure you're still connected to your VPN!

    0 讨论(0)
  • 2020-12-13 00:08

    That was happened when i suddenly renamed class of old migration that already exist in db. I checked VCS history, determined that and renamed back. All worked afterwards.

    0 讨论(0)
  • 2020-12-13 00:08

    I did another way. I droped database entirely and run "update-database" again in vs.

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