This time, I’m happy to present you perhaps the simplest way of fixing an annoying and persistent issue with a misleading error message! Wait, does that sound familiar? It’s almost like that’s what half of my articles are about…
Anyway, I was happily going my way about creating a couple of new fields to an entity and then scaffolding my changes to a new migration using Entity Framework Core’s Add-Migration, but this happened:
Build started... Build failed.
“Oh”, I thought. “I must have messed something up and the build is broken.”
Well, I hit Ctrl+Shift+B, and build passed just fine.
Wait, what now?
My project was building, debugging, rebuilding etc. just fine, but failed to run Add-Migration, or Remove-Migration or Update-Database for that matter!
What in tarnation
Below is what it looked like in the Package Manager Console:
As you can see, specifying -Verbose didn’t help at all, making sure the Default project is the correct one, and even specifying -Context and -Project made no change.
So, what gives?
Okay, so once again, this is going to be a bit stupid! But that’s the way I like to bang my head on the keyboard, so…
Check the other projects in your solution and see whether they build or not.
For me, it was another project that was just a bit broken and wouldn’t build – that caused me no issues with my normal development workflow (it was a tooling project only occasionally used), but Entity Framework Core commandlets require all of the projects to be kosher in order to run successfully.
So, that solved it for me. Let me know if whether it helped you or not! :)
- How to recover the private key of a (.pfx) certificate? - January 20, 2021
- How to fix “System.IO.FileSystem: Could not find a part of the path \AppData\Local\AzureFunctionsTools\Releases\3.17.0\workers. Value cannot be null. (Parameter ‘provider’)” when running Azure Functions locally? - January 12, 2021
- How to nuke the Identity Cache in Visual Studio? - January 11, 2021