Have to change present working directory to project in solution to use EF Core CLI tools
See original GitHub issueI have installed EF Core in a library project which is then referenced in my ASP.NET Core application.
When finally I got the package Microsoft.EntityFrameworkCore.Tools.Dotnet
installed, I was unable to use the dotnet ef
commands until or unless I change my present working directory in Package Manager Console to that project.
Project Structure
`
- Project
- Project.Lib
- Project.Data
- Other Libraries
- Project.Web
- Project.Web.Portal
- Other Web Projects `
- Project.Lib
The present working directory is set to Project
and the Default Project
in Package Manager Console is set to Project.Data
.
Steps to reproduce
Follow the project structure mentioned above and then try to run the following command after installing the Microsoft.EntityFrameworkCore.Tools.Dotnet
package:
dotnet ef
Expected Behaviour
PM> dotnet ef
Entity Framework Core .NET Command Line Tools 1.0.1-rtm-10418
Usage: dotnet ef [options] [command]
Options:
--version Show version information
-h|--help Show help information
-v|--verbose Show verbose output.
--no-color Don't colorize output.
--prefix-output Prefix output with level.
Commands:
database Commands to manage the database.
dbcontext Commands to manage DbContext types.
migrations Commands to manage migrations.
Use "dotnet ef [command] --help" for more information about a command.
PM>
Current Behaviour
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
Workaround
Change present working directory to Project.Lib/Project.Data
:
PM> cd Project.Lib/Project.Data
Now If I use the dotnet ef
command, it works perfectly fine.
Further Details
I’m creating this issue because, in Entity Framework 6, it doesn’t matter in which project EF is installed. I could simply use EF 6 commands from the Package Manager Console without changing my present working directory. I just had to make sure the Default Project
option of the Package Manager Console is set to the class library project which has EF 6 installed.
I’m curious whether this behavior is intended or a consequence of ‘everything-as-a-package’ pattern .NET Core follows.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:9 (6 by maintainers)
We strongly recommend using the PMC commands (
Add-Migration
,Update-Database
, etc.) inside NuGet’s Package Manager Console since they provide a more integrated experience. Install theMicrosoft.EntityFrameworkCore.Tools
package to use them.@ajcvickers Hello there, the PMC commands works perfectly fine. Just started to use them, and yes you’re right, none of the tutorials available online use the PMC commands. All of them use the .NET CLI ones. This was the major reason I didn’t know about their compatibility with EF Core and Npgsql.