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

  • Question

  • User-53724977 posted

    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 command<sup>1</sup>:

    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 message<sup>2</sup>:

    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\tools.store\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.

    Tuesday, April 27, 2021 2:45 PM

All replies

  • User1358036820 posted

    Have you just tried using a dotnet new to create a project that already uses EF Core and sets it all up so you don't need to?  

    Tuesday, April 27, 2021 3:58 PM