EF Core Error - No project was found. Change the current working directory or use the --project option

.net-core dotnet-cli ef-code-first ef-migrations entity-framework-core

Question

I am using Visual Studio 2015 and dotnet core and trying to develop an EF Core Code First project using Sqlite and this documentation / tutorial, which also uses Sqlite => NET Core - New Database

When I try to add an initial migration from the command line ( I am CD-ed into the folder that my data model project is located in) by issuing the following command

dotnet ef migrations add InitialMigration

...I get the following Error.

enter image description here

No project was found. Change the current working directory or use the --project option.

I even tried using the --project option like so.

> dotnet --project "C:\Shiva\EF\EFCFSqlite.Data.xproj"  ef migrations add InitialMigration

but that gives the following error.

Unknown option: --project
.NET Command Line Tools (1.0.0-preview2-003131)
Usage: dotnet [host-options] [command] [arguments] [common-options]

I noticed that the documentation is using .csproj file whereas my Project is showing a xproj file. Also the docs mention something about not using project.json anymore :(

Here's my project.json file.

{
  "version": "1.0.0-*",

  "dependencies": {
    "Microsoft.EntityFrameworkCore.Sqlite": "1.1.1",
    "Microsoft.EntityFrameworkCore.Sqlite.Design": "1.1.1",
    "NETStandard.Library": "1.6.1"
  },
  "tools": {
    "Microsoft.EntityFrameworkCore.Tools.DotNet":"1.0.0"
  },
  "frameworks": {
    "netstandard1.6": {
      "imports": "dnxcore50"
    }
  }

What has changed? Do we have no choice but to Install Visual Studio 2017 and start from scratch?? Is project.json and all this other stuff no longer honored?

Seems like a massive change to me if that's the case :(

1
24
3/24/2017 5:00:05 AM

Accepted Answer

Instead of:

"tools": {
    "Microsoft.EntityFrameworkCore.Tools.DotNet":"1.0.0"
  },

try:

"tools": {
      "Microsoft.EntityFrameworkCore.Tools.DotNet": {
      "version": "1.0.0-preview3-final"
  }},
11
3/24/2017 6:41:39 PM

Popular Answer

sometimes you need to change the current directory in console/terminal eg:

PM> cd E:\Projects\CrossTest\
PM> dotnet ef migrations add InitialMigration

and Align your package versions. Either use preview1 packages or preview2. Mix of those are not supported.



Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow