I've been working on the basics of an ASP.Net Core MVC Project and I'm wondering why I can't create my initial Migration.
I go into the project folder and run "dotnet ef" in CMD and get an error of "No executable found matching command dotnet-ef".
I figure that this is odd, so I try to build my application in VS2017 and I get this error:
Severity Code Description Project File Line Suppression State
Error NU1605 Detected package downgrade: Microsoft.NETCore.App from 2.0.6
to 2.0.0. Reference the package directly from the project to select a
different version.
FiberLocator -> Microsoft.EntityFrameworkCore.Tools.DotNet 2.0.2 ->
Microsoft.NETCore.App (>= 2.0.6)
FiberLocator -> Microsoft.NETCore.App (>= 2.0.0) FiberLocator
C:\Users\user\Google Drive\ASP.Net Core
Projects\FiberLocator\FiberLocator.csproj 1
My .csproj file looks like this.
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Folder Include="Data\Migrations\" />
<Folder Include="wwwroot\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.6" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.0.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="2.0.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.0.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.0.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.0.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.2" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.0.3" />
</ItemGroup>
</Project>
From what i understand, the ..Tools.DotNet is the package that gets me the ability to use "dotnet ef". I even tried setting the version to the latest at this time of writing (a preview build even) and it still wouldn't work, giving me the "unknown command" error from above.
How can I change my NETCore.App package to 2.0.0, or allow the Tools.DotNet package to be compatible? There isn't a later version than 2.0.2 on the NuGet site, so I have no idea what to do here.
Any help is appreciated.
Thanks
Microsoft.EntityFrameworkCore.Tools.DotNet
is dotnet-ef command line tool. In order to use it in your project change the element referencing it in your csproj
from PackageReference to DotNetCliToolReference. Like so:
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.2" />
Version 2.0.2
requires Microsoft.NETCore.App (>= 2.0.6)
. So you should be ok. For more versions and dependencies have a look at: nuget.org
Microsoft.EntityFrameworkCore.Tools
contains equivalent tools, but for Nuget's Package Manager Console in Visual Studio