I am only recently getting the following exception when running dotnet ef
or the Entity Framework CLI dotnet tool.
I even reset Windows 11 and still I get the same error.
Nothing I have tried has been able to resolve this issue.
The issue happens when I attempt to run dotnet ef
- I immediately see this error:
Failed to create CoreCLR, HRESULT: 0x80004005
Furthermore, several other dotnet
tools no longer work..
tye, dotnet-graphql and webcompiler.
This seems to suggest that issues is related to runtime on the machine.
I think this had something to do with missing .Net 6 libraries but honestly not sure what resolved the issues but after I ran the installers for .Net 6 (ASP.NET, SDK) and ran a repair on Visual Studio Installer the issue was mitigated.
I'm going to chime in on this one because this recently affected me with .NET 7 and .NET 8 on a Mac.
I've come to the conclusion, that for me, it was because .NET was inappropriately resolving a nuget package meant for .NET 8 to a .NET 7 project. It was the EntityFrameworkCore.Design package that was missing from a .NET 7 project, so the underlying links would resolve to the .NET 8 version and that killed dotnet ef. The way I found out was to completely remove all installations of dotnet on my mac and reinstall the offending SDK only. That's when I realized my project was missing one package. Because there were no indications there was anything wrong without it, I didn't see that until I wiped my computer clean of dotnet.
The IDE and underlying project would resolve fine, it wouldn't say there were any missing dependencies. Everything seemed to be OK, but whenever I tried to run dotnet ef --anything database related--
it would fail with the dreaded:
Failed to create CoreCLR, HRESULT: 0x80004005
And there were no errors or anything. I tried looking up online the issue and tried several different things that others were saying to do: looking at environment variables, turning on trace when running dotnet ef, all the things and there wasn't anything that seemed out of place.
It just seemed to fail for no reason. Then I started thinking about the nuke option, completely remove everything dotnet related and re-install which means wiping everything (excluding my projects of course) including the .nuget
and .dotnet
folders in my local directory.
When listed my SDK's, I had a bunch going all the way back to AspNetCore 2.1. So I just pushed the big red button and deleted the entire dotnet folder in my /usr/local/shared folder. After that, I only installed .NET 7 to start so that I could troubleshoot what the heck was going on. I booted up my project and low and behold there was a missing nuget package in the project. Sheisse eh! was what I was thinking.
It was kind of painful to get through that because I had no indications of a missing package through the system so it was doing something wrong with resolving a missing package for .NET 7 project on the .NET 8 SDK and it was only caught via dotnet ef --do something database related--
command.
Hope this helps someone else out there. The package resolver is not quite 100% sometimes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With