Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding Microsoft.EntityFrameworkCore.Tools to a ASP.NET Core project

I am creating a new ASP.NET Core project using dotnet 4.5.2 and am trying to add a reference to Microsoft.EntityFrameworkCore.Tools. In my project.json file I have these listed under dependencies:

 "Microsoft.EntityFrameworkCore.SqlServer": "1.0.0",
 "Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview2-final"

Looking under References, they appear to be successfully loaded. I then added this under tools in project.json:

"Microsoft.EntityFrameworkCore.Tools": {
  "imports": [ "portable-net451+win8" ],
  "version": "1.0.0-preview2-final"
}

After I added that, when I build the solution I get this build error:

Could not find a part of the path 'C:\Users\(my user name)\.nuget\packages\.tools\Microsoft.EntityFrameworkCore.Tools'

I get the same error if I remove the imports line. What am I doing wrong here?

like image 560
Rono Avatar asked Jul 16 '26 03:07

Rono


2 Answers

Just ran into the same issue. I fixed the issue by installing the tools package again in the package manager console:

Install-Package Microsoft.EntityFrameworkCore.Tools –Pre

Before reinstalling the package was actually missing in the .nuget\packages.tools folder, after reinstalling it was there.

I followed the https://docs.efproject.net/en/latest/platforms/aspnetcore/new-db.html tutorial, but I think I installed the package in the wrong order or initially forgot to reference the EF.tools package in the "tools" section of the project json.

like image 52
Martijn Kooij Avatar answered Jul 18 '26 02:07

Martijn Kooij


I had this same problem and just solved using the examples from the EF Core setup guide from Microsoft, checking their GitHub code as well, I found this to work for the project.json.

I had to remove the imports from the "frameworks" property, which means no Application Insights for now. Once I did this and built, the folder appeared in the tools folder. Sorry I'm not good at posting code here but here are the important parts, ... elipses used to trim the post of my other things:

"dependencies": {
...
"Microsoft.EntityFrameworkCore": "1.0.0",
"Microsoft.EntityFrameworkCore.SqlServer": "1.0.0",
"Microsoft.EntityFrameworkCore.SqlServer.Design": "1.0.0",
"Microsoft.EntityFrameworkCore.Tools": {
  "version": "1.0.0-preview2-final",
  "type": "build"
}  ...},

"tools": {
"Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview2-final",
"Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final"
},

"frameworks": {
"netcoreapp1.0": {

}...
like image 38
Kbalz Avatar answered Jul 18 '26 02:07

Kbalz