efcore icon indicating copy to clipboard operation
efcore copied to clipboard

dotnet ef not working in VS 2017

Open jrock2004 opened this issue 10 years ago • 51 comments

Steps to reproduce

  • Install VS 2017 RC
  • Create brand new web application with authentication
  • Add the require dependencies for migration builder
  • Open the package manager console and type dotnet ef

The issue

So I upgraded to Visual Studio 2017 and generated a new .net core web application with docker support. I am trying to create a new migration and getting an error about not finding an executable. When I installed 2017 I did check to install .NET core.

I went to look for the project.json file but there is none. I added a nuget package and I still cannot get it to generate a migration file for me.

"Microsoft.EntityFrameworkCore.Design"

If you are seeing an exception, include the full exceptions details (message and stack trace).

Exception message:
Stack trace:
PM> dotnet ef
dotnet : No executable found matching command "dotnet-ef"
At line:1 char:1
+ dotnet ef
+ ~~~~~~~~~
    + CategoryInfo          : NotSpecified: (No executable f...and "dotnet-ef":String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError
 

Further technical details

Operating system: Windows 10 Visual Studio version: (e.g. VS 2013 or n/a) VS 2017

jrock2004 avatar Nov 17 '16 04:11 jrock2004

Maybe this helps: https://docs.microsoft.com/en-us/ef/core/miscellaneous/cli/powershell

12michel34 avatar Nov 17 '16 10:11 12michel34

Some problem on Linux

uname -a Linux msmaldi-pc 4.8.0-1-amd64 #1 SMP Debian 4.8.5-1 (2016-10-28) x86_64 GNU/Linux

Microsoft.NETCore.App | 1.1.0 Microsoft.EntityFrameworkCore.Tools | 1.1.0-preview4-final

Microsoft .NET Core Shared Framework Host Version : 1.1.0 Build : 928f77c4bc3f49d892459992fb6e1d5542cb5e86

No executable found matching command "dotnet-ef"

msmaldi avatar Nov 17 '16 11:11 msmaldi

@jrock2004 Look at this post https://blogs.msdn.microsoft.com/dotnet/2016/11/16/announcing-entity-framework-core-1-1/

Have you done this command PM> Install-Package Microsoft.EntityFrameworkCore.Tools.DotNet -Version 1.0.0-msbuild1-final -Pre

cdie avatar Nov 17 '16 11:11 cdie

@cdie I tried that and I got the following

PM> Install-Package Microsoft.EntityFrameworkCore.Tools.DotNet -Version 1.0.0-msbuild1-final -Pre
  GET https://api.nuget.org/v3/registration1-gz/microsoft.entityframeworkcore.tools.dotnet/index.json
  OK https://api.nuget.org/v3/registration1-gz/microsoft.entityframeworkcore.tools.dotnet/index.json 140ms
  GET https://www.myget.org/F/booker-core/auth/9038fb26-5b58-4125-a2f2-ec8327b318e6/api/v3/registration1/microsoft.entityframeworkcore.tools.dotnet/index.json
Restoring packages for C:\Development\AndroidAppAddictsApp\src\AndroidAppAddictsApp\AndroidAppAddictsApp.csproj...
Install-Package : Package 'Microsoft.EntityFrameworkCore.Tools.DotNet 1.0.0-msbuild1-final' has a package type 'DotnetCliTool' that is not supported by project 'src\AndroidAppAddictsApp'.
At line:1 char:1
+ Install-Package Microsoft.EntityFrameworkCore.Tools.DotNet -Version 1 ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Install-Package], Exception
    + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand

Time Elapsed: 00:00:04.5577762****

@12michel34 I tried your link and this is what I get

PM> Add-Migration -Name CreateAppsSchema
The specified framework 'Microsoft.NETCore.App', version '1.1.0' was not found.
  - Check application dependencies and target a framework version installed at:
      C:\Program Files\dotnet\shared\Microsoft.NETCore.App
  - The following versions are installed:
      1.0.1
  - Alternatively, install the framework version '1.1.0'.
Process finished with non-zero exit code

jrock2004 avatar Nov 17 '16 14:11 jrock2004

@jrock2004 It seems that you haven't installed the latest SDK for .NET Core. You can find it here https://go.microsoft.com/fwlink/?LinkID=835014

Then, retry 2michel34's link

cdie avatar Nov 17 '16 14:11 cdie

My problem as solved when i add in project.json "Microsoft.EntityFrameworkCore.Tools.DotNet": "1.0.0-msbuild1-final"

msmaldi avatar Nov 17 '16 14:11 msmaldi

@cdie Yep that did it. After installing that I could run the command successfully Add-Migration -Name CreateAppsSchema

jrock2004 avatar Nov 17 '16 14:11 jrock2004

@jrock2004 are we good to close this one now? I think everything you needed was captured in blog post? If not, let me know and we will add the missing info.

rowanmiller avatar Nov 17 '16 15:11 rowanmiller

I want to check if command line still works.

jrock2004 avatar Nov 17 '16 16:11 jrock2004

@jrock2004 - If it is project.json based project then you need to change current directory to directory containing project.json file. Above error is also throw if dotnet cannot find project.json in current directory.

smitpatel avatar Nov 17 '16 19:11 smitpatel

There won't be a project.json if this is VS2017. Just make sure to read the guidance in the blog post as you can't have both Package Manager Console and dotnet ef work in the same project for this release. Of course, you can add/remove the packages as needed to swap between the two. But if you are in VS, we would recommend using the Package Manager Console commands.

rowanmiller avatar Nov 17 '16 19:11 rowanmiller

Is this the final decision with project.json ??? We just got used to it :(

freerider7777 avatar Nov 18 '16 12:11 freerider7777

@cdie Thx for the link, I installed VS 2017, new project - update nuget packages (to 1.1) - and it did not run after that... Though it's strange why it's not installed with VS.

freerider7777 avatar Nov 18 '16 12:11 freerider7777

@freerider7777 The problem is with VS 2017 generated projects no longer have a project.json file. If you generate via command line or yoeman generator you still get the project.json

jrock2004 avatar Nov 18 '16 12:11 jrock2004

@jrock2004 For sure yoeman does not know yet :)) Connect was just a couple of days ago. Why did Microsoft decide to get rid of project.json?

freerider7777 avatar Nov 18 '16 13:11 freerider7777

could not make dotnet ef to run... :(( VS 2017 windows 7...

freerider7777 avatar Nov 18 '16 13:11 freerider7777

@freerider7777 take a look at https://blogs.msdn.microsoft.com/dotnet/2016/11/16/announcing-net-core-tools-msbuild-alpha/ for info on why project.json is being retired. If you are still having issues with dotnet ef in VS2017 after following the guidance at the end of https://blogs.msdn.microsoft.com/dotnet/2016/11/16/announcing-entity-framework-core-1-1/, then open up a new issue.

rowanmiller avatar Nov 18 '16 19:11 rowanmiller

@rowanmiller ok, thx..I've read everything. I see for now VS is rather loosey goosey :) dotnet ef not compatible with package manager comman line...

freerider7777 avatar Nov 18 '16 19:11 freerider7777

@freerider7777 dotnet ef isn't for use in Package Manager Console, it's for use outside of VS at the command line. You would use the Package Manager Console commands in Microsoft.EntityFrameworkCore.Tools (Add-Migration, Update-Database, etc.).

rowanmiller avatar Nov 18 '16 19:11 rowanmiller

@rowanmiller for you it's obvious, for us not... in VS code you just run npm start as in normal command line. Also the templates for project do not reference 1.1 packages - some work is yet to be done for VS to work 'out of the box' :)

freerider7777 avatar Nov 18 '16 20:11 freerider7777