Installing Entity Framework Core fails with hostfxr.dll could not be found

Last Reply 14 days ago By dharmendr

Posted 15 days ago

"Installing" Entity Framework Core fails with "hostfxr.dll" could not be found

I would like to utilise Entity Framework Core in order to create my web application database schema and other migrations features.

Since it is no longer shipped as an integral part of the .NET framework, I decided to install it using the command1:

dotnet tool install --global dotnet-ef

I receive the prompt thinking it is successfully installed and that I may interact with it in the console:

You can invoke the tool using the following command: dotnet-ef Tool 'dotnet-ef' (version '5.0.5') was successfully installed.

As above, I am told I "can invoke" the tool and that it is "successfully" installed. But when invoking the command dotnet-ef, I find that I can not invoke the tool and that it is not successfully installed as I receive the error message2:

A fatal error occurred. The required library hostfxr.dll could not be found. If this is a self-contained application, that library should exist in [C:\Users\DejanP.dotnet\\dotnet- ef\5.0.5\dotnet-ef\5.0.5\tools\netcoreapp3.1\any]. If this is a framework-dependent application, install the runtime in the global location [C:\Program Files\dotnet] or use the DOTNET_ROOT environment variable to specify the runtime locat

The .NET Core runtime can be found at:

I have two comments on this prompt:

  1. Upon inspection, there indeed is not file of that name in the stated directory. Upon searching however, I do find such a file in the directory:


  2. I can't begin to action the hints in the prompt as I don't know if my application is self-contained or framework-dependent

I would be tremendously grateful if someone could assist whilst noting my specific environment:

  • Op System: MS Windows 10 Pro, version 1709, OS Build 16299.1087
  • IDE: Jet Brains Rider 2021.1.2
  • .NET environment: .NET Core
  • .NET version: 5.0.202
  • Application that I am building: ASP.NET Core Web Application

The jargon I have used may come across as if I am verse in this tech stack but I am very new to all this and would appreciate some guidance using first principles and the assumption that I know almost nothing.

You are viewing reply posted by: dharmendr 14 days ago.