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 authenticate against Azure Key Vault both in Azure and local development environment? - October 26, 2021
- System.Text.Json.JsonPropertyName not working for CosmosDb in .NET Core/5? - October 19, 2021
- Errors loading an assembly that’s using Microsoft Graph API - October 12, 2021