Vous êtes sur la page 1sur 5

aspnet / EntityFrameworkCore

No executable found matching command "dotnet-ef" New issue

even after adding CLI #8996


Closed mehtanilay10 opened this issue on Jun 28 21 comments

mehtanilay10 commented on Jun 28 Assignees

No one assigned
I want to Migrate my Database with Models. I am using EF Core 2.0 Preview.
Labels

dotnet ef migrations add InitialCreate


closed-question
dotnet : No executable found matching command "dotnet-ef"

Projects
Packahe & Tools None yet

I am already added all CLI and PM but still got error!


Milestone

<ItemGroup> No milestone
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0-preview2-final" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="2.0.0-pre
Notifications
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.0.0-preview2-final" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer.Design" Version="2.0.0-previe
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.0.0-preview2-final" / 8 participants
</ItemGroup>

<ItemGroup>
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.0
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.0-
</ItemGroup>

Further technical details


EF Core version: 2.0 Preview
Database Provider: Microsoft.EntityFrameworkCore.SqlServer
Operating system: Windows 10 15063.0
IDE: Visual Studio 2017 Preview

bricelam commented on Jun 28 edited Member

Ensure...

1. You're using the .NET Core SDK 2.0


2. You ran dotnet restore on the project
3. You cd ed to the project's ( *.csproj ) directory

mehtanilay10 commented on Jun 28

Yes, i am using 2.0 SDK and tried for dotnet restored on project but still got same error.

mehtanilay10 commented on Jun 28


I am uploaded entire solution on github. CodeFirst is a project, which i want to Migrate and generate error.
https://github.com/mehtanilay10/EntityFrameworkCore

smitpatel commented on Jun 28 Contributor

Align your package versions.


Either use preview1 packages or preview2. Mix of those are not supported.

smitpatel commented on Jun 28 Contributor

Also to use dotnet ef correctly, you need to install Microsoft.EntityFrameworkCore.Design package.

mehtanilay10 commented on Jun 28

Added Microsoft.EntityFrameworkCore.Design and also change all to packages to preview1 still facing
same error!

smitpatel commented on Jun 28 Contributor

Does running dotnet build pass?

mehtanilay10 commented on Jun 28 edited

yes, project build successfully. But gives only error for CLI

bricelam commented on Jun 29 Member

...and you're certain dir lists your *.csproj and dotnet --info says 2.0.0?

bricelam commented on Jun 29 Member

(I know these are stupid questions, but I honestly have no idea what could be going wrong.)

1 1

bricelam commented on Jun 29 Member

You may need to follow up on dotnet/cli. Something is going wrong before the EF code gets a chance to
run.

mehtanilay10 commented on Jun 29

.NET Command Line Tools (2.0.0-preview1-005977)

Product Information:
Version: 2.0.0-preview1-005977
Commit SHA-1 hash: 414cab8a0b

Runtime Environment:
OS Name: Windows
OS Version: 10.0.15063
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\2.0.0-preview1-005977\
Microsoft .NET Core Shared Framework Host
Version : 2.0.0-preview1-002111-00
Build : 1ff021936263d492539399688f46fd3827169983

mehtanilay10 commented on Jun 29

If you want to check on my machine then i will give remote access, so you can see what's going wrong.

smitpatel commented on Jun 29 edited Contributor

I cloned the repo posted.


Updated the CodeFirst.csproj as follows.

<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
<MvcRazorCompileOnPublish>true</MvcRazorCompileOnPublish>
<UserSecretsId>aspnet-CodeFirst-DB7142CA-3EB8-4FB3-9C4A-0173586B87FB</UserSecretsId>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0-preview1-final" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="2.0.0-pre
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.0.0-preview1-final" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer.Design" Version="2.0.0-previe
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.0.0-preview1-final" /
</ItemGroup>

<ItemGroup>
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.0
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.0-
</ItemGroup>

</Project>

In the directory D:\EntityFrameworkCore\EntityFramework\CodeFirst


dotnet restore
dotnet ef
and it worked.

I had to remove PackageTargetFallback due to this NuGet/NuGet.Client#1495 and I could not find where
AssetTargetFallBack is set.

mehtanilay10 commented on Jun 29

@smitpatel Thanks a lot for solving this issue ;)


Finally it was removed error from CMD but when i am using package manager in VS 2017 15.3 it gives same
error. May be this is VS's Issue.

smitpatel commented on Jun 29 edited Contributor


By default Package Manager Console (PMC) is rooted at dir containing the solution file.
dotnet ef requires to be operated in directory containing csproj file. The only way to invoke dotnet ef
in PMC, you need to manually cd into the correct folder where your csproj file is located. Changing anything
else in PMC has no effect current directory.

For best user experience, use PMC commands for EF (Add-Migration & friends) in PMC.

smitpatel closed this on Jun 29

smitpatel added the closed-question label on Jun 29

mehtanilay10 referenced this issue in dotnet/core on Jun 30

No executable found matching command "dotnet-ef" even after adding CLI #712 Closed

timpur commented on Sep 4

I has this issue and like to share.

i had the Microsoft.EntityFrameworkCore.Tools.DotNet as <PackageReference> because i uesd the GUI


package manager to install it.

when i changed it to <DotNetCliToolReference> and then dotnet restore , this fixed it.

eg Use:
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.0" />
Not
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.0" />

14

JeanVanDenderFlume commented on Sep 10 edited

That last thing worked for me


In my case i had to change both \library-management\LibraryData\LibraryData.csproj and \library-
management\Library\Library.csproj from to

My God, this library mangement is from github, orginally a core 1.1 web app I hope realy with 2.0 and
webpack things will be stable and change too much.

AliBayatGH commented on Oct 6 edited

This worked for me:


The EF tools for the CLI are provided in Microsoft.EntityFrameworkCore.Tools.DotNet. To install this package,
add it to the DotNetCliToolReference collection in the .csproj file, You have to install this package by editing
the .csproj file; you can't use the install-package command or the package manager GUI. You can edit the
.csproj file by right-clicking the project name in Solution Explorer and selecting Edit XXX.csproj.

<ItemGroup>
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.0" />
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools"
Version="2.0.0" />
</ItemGroup>

4
ralmsdeveloper referenced this issue 27 days ago

Want to migrate on dnx to cli with entity framework core #10196 Closed

veneMarcos commented 27 days ago edited by bricelam

I hade the some trouble and I fix this change the Microsoft.EntityFramework.Tools.Dotnet from the First
<ItemGroup> like this:

<PackageReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.0" />

For a second <ItemGroup> tag represent the DotNetCliToolReference:

<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.0" />

huoxudong125 commented 5 days ago edited

It's a pity for new one(.net core user).

dotnet : dotnet-ef

.NET (2.0.3)

Product Information:
Version: 2.0.3
Commit SHA-1 hash: 12f0c7efcc

Runtime Environment:
OS Name: Windows
OS Version: 10.0.15063
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\2.0.3\

Microsoft .NET Core Shared Framework Host

Version : 2.0.3
Build : a9190d4a75f4a982ae4b4fa8d1a24526566c69df

in powershell dotnet ef throw new exception:

Could not load type


'Microsoft.EntityFrameworkCore.Infrastructure.DesignTimeProviderServicesAttribute' from assembly
'Microsoft.EntityFrameworkCore, Version=2.0.1.0, Culture=neutral,
PublicKeyToken=adb9793829ddae60'.

Is there is a simple way to use this commands or have a good tutorial?

Vous aimerez peut-être aussi