Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Failed to create CoreCLR, HRESULT: 0x80004005 when trying to run Entity Framework CLI

I am only recently getting the following exception when running dotnet ef or the Entity Framework CLI dotnet tool.

  • I tried uninstalling and reinstalling EF CLI tool
  • I tried uninstalling and reinstalling .NET 7 SDK
  • I tried uninstalling and reinstalling VS Code
  • I tried uninstalling and reinstalling VS 2022 Community edition

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.

like image 748
John Kears Avatar asked Sep 14 '25 09:09

John Kears


2 Answers

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.

like image 118
John Kears Avatar answered Sep 17 '25 12:09

John Kears


I'm going to chime in on this one because this recently affected me with .NET 7 and .NET 8 on a Mac.

TLDR;

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.

Longer Version

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.

like image 21
Paul Carlton Avatar answered Sep 17 '25 14:09

Paul Carlton