Enabling Entity Framework Core 1.1 tools

After I created an ASP .NET Core 1.1 project (Console app) with Visual Studio 2017 to develop a new WebAPI, I wanted to add support for EntityFrameworkCore. Everything was OK, except for the Tools.DotNet package, which I couldn’t add with NuGet package manager to be able to call “dotnet ef” commands in the Package Manager Console (such as to scaffold items for database first development).

To resolve the issue (note that there is no more project.json as indicated in some tutorials to use as a project folder selector – now it’s using the .csproj file itself) I had to do these together (skipping any of them would turn everything into a failure):

  • Manually add the Tools.DotNet package in the .csproj file using the correct version:
    <ItemGroup>
        <DotNetCliToolReference
            Include="Microsoft.EntityFrameworkCore.Tools.DotNet"
            Version="1.0.1"/>
    </ItemGroup>
    
  • Run the dotnet ef command after switching to the project folder in Package Manager Console. Note that by default, the console opens in the solution folder!
    cd {ProjectFolder}
    dotnet ef ...
Advertisements

About Sorin Dolha

My passion is software development, but I also like physics.
This entry was posted in .NET, ASP .NET, Miscellaneous, WebAPI and tagged , , . Bookmark the permalink.

Add a reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s