Trying to install tooling do run dotnet ef commands
Retrieving package 'Microsoft.EntityFrameworkCore.Tools.DotNet 1.1.0-preview4-final' from 'nuget.org'.
Install failed. Rolling back...
Package 'Microsoft.EntityFrameworkCore.Tools.DotNet.1.1.0-preview4-final' does not exist in project 'App'
Executing nuget actions took 620.74 ms
Package 'Microsoft.EntityFrameworkCore.Tools.DotNet 1.1.0-preview4-final' has a package type 'DotnetCliTool' that is not supported by project 'App'.
EF Core version: 1.1.0
[assembly: AssemblyFileVersion ("1.1.0.21115")]
[assembly: AssemblyInformationalVersion ("1.1.0-rtm-22752")]
Operating system:
Visual Studio for Mac OSX 10.12.21
Other details about my project setup:
dotnet --version 1.0.0-preview3-004056
sdk 1.0.0-preview3-004056 (/usr/local/share/dotnet/sdk
NuGet currently doesn't support installing .NET CLI Tool packages. You need to manually edit the project.json to register it...
"tools": {
"Microsoft.EntityFrameworkCore.Tools.DotNet": "1.1.0-preview4-final"
},
Closing as I think I have answered this, but reply if not and I will reopen.
Thanks will try it out!
Since I'm running Visual Studio for Mac I added it to .csproj as follows
c#
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet">
<Version>1.1.0-preview4-final</Version>
</PackageReference>
The file package.json was nowhere to be found and, as far as I've read, it pretty much has been replaced by .csproj(correct me if I'm wrong - new to .NET core).
Well enough rambling: it still doesn't work.
$ dotnet ef
No executable found matching command "dotnet-ef"
So I found a package.json file and included it as well and added the tools section. dotnet restore does nothing but nuget restore try to do something, but fails since there is missing pieces.
Currently this is my package.json (probably completely incorrect)
````
{
"dependencies": {
"Microsoft.NETCore.App": {
"version": "1.0.0-rc2-3002702"
},
"Microsoft.AspNetCore.Mvc": "1.0.0-rc2-final",
"Microsoft.AspNetCore.Server.IISIntegration": "1.0.0-rc2-final",
"Microsoft.AspNetCore.Server.Kestrel": "1.0.0-rc2-final",
"Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0-rc2-final",
"Microsoft.Extensions.Configuration.FileExtensions": "1.0.0-rc2-final",
"Microsoft.Extensions.Configuration.Json": "1.0.0-rc2-final",
"Microsoft.Extensions.Logging": "1.0.0-rc2-final",
"Microsoft.Extensions.Logging.Console": "1.0.0-rc2-final",
"Microsoft.Extensions.Logging.Debug": "1.0.0-rc2-final",
"Microsoft.EntityFrameworkCore": "1.0.0-rc2-final"
},
"tools": {
"Microsoft.EntityFrameworkCore.Tools": {
"version": "1.0.0-preview1-final",
"imports": [
"portable-net45+win8+dnxcore50",
"portable-net45+win8"
]
}
},
"frameworks": {
"netcoreapp1.0": {
"imports": [
"dotnet5.6",
"dnxcore50",
"portable-net45+win8"
]
}
},
"buildOptions": {
"emitEntryPoint": true,
"preserveCompilationContext": true
},
"runtimeOptions": {
"gcServer": true
},
"publishOptions": {
"include": [
"wwwroot",
"Views",
"appsettings.json",
"web.config"
]
},
"scripts": {
"postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
}
}
```
The output fromnuget restore` is
````
Restoring packages for tool 'Microsoft.EntityFrameworkCore.Tools' in /Users/.../src/App/project.json...
GET https://api.nuget.org/v3-flatcontainer/microsoft.entityframeworkcore.tools/index.json
OK https://api.nuget.org/v3-flatcontainer/microsoft.entityframeworkcore.tools/index.json 516ms
GET https://api.nuget.org/v3-flatcontainer/microsoft.entityframeworkcore.tools/1.0.0-preview1-final/microsoft.entityframeworkcore.tools.1.0.0-preview1-final.nupkg
OK https://api.nuget.org/v3-flatcontainer/microsoft.entityframeworkcore.tools/1.0.0-preview1-final/microsoft.entityframeworkcore.tools.1.0.0-preview1-final.nupkg 560ms
Installing Microsoft.EntityFrameworkCore.Tools 1.0.0-preview1-final.
Committing restore...
/Users/.../src/App/project.json
Restore completed in 230965ms.
NuGet Config files used:
/Users/user/.config/NuGet/NuGet.Config
Feeds used:
https://api.nuget.org/v3/index.json
Installed:
193 package(s) to /Users/.../src/App/project.json
````
Where those 193 packages went I've no idea and for what reason they were even installed I don't understand (perhaps the different frameworks dnxcore,dnx,portable and so on that is not part of .netstandard1.1 that my app is targeting)
Anyhow: it still doesn't work. Any clues?
What is the plan for .csproj and project.json? Will both be needed when running Visual Studio for Mac?
````
````
@rowanmiller Do you have any ideas what might be wrong? Don't know what to try next - running out of ideas
For preview3 (csproj-based) tooling, you'll need to add the following.
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet">
<Version>1.0.0-msbuild1-final</Version>
</DotNetCliToolReference>
Also, I don't think the 1.1 runtime is supported on the preview3 tooling. At the least, you'll probably need to add the following package references. But even then it still may not work.
<PackageReference Include="Microsoft.EntityFrameworkCore.Design">
<Version>1.1.0</Version>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools">
<Version>1.0.0-msbuild1-final</Version>
</PackageReference>
@bricelam That did the trick. Unfortunately after running it the first time I can't run dotnet ef again. Get **no executable matchin 'dotnet-ef'
Edit After running the tool the reference Microsoft.EntityFrameworkCore.Tools.DotNet was removed
Edit2 There is a file added to VS for Mac with the name Microsoft.EntityFrameworkCore.Tools.DotNet and first time I removed it (since VS say it doesn't exists). Might be because of that the tooling stopped working. I will leave it now when it works :)
Yep. Definitely still a preview. Personally, I'm surprised to hear that VS for Mac works at all with MSBuild .NET Core projects.
It doesn't work as well as one had hopped though :). Struggling with referencing a Core class library (netstandard1.6) in my asp.net core web (.netcoreapp1.1).
Referencing it directly make it compile but then the assembly file cannot be found. Tried to add it to my "local nuget feed" and install it but that fails since it wants to upgrade the tooling (but fails).
Third try adding it to .csproj directly and performing dotnet clean && dotnet restore adds the nuget but cannot find the assembly.
any luck adding "Microsoft.EntityFrameworkCore.Tools.DotNet" on visual studio for mac? I am using dotnet version 1.0.0-preview3-004056
@vivek306 Yes! Paste below in ItemGroup
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet">
<Version>1.0.0-msbuild1-final</Version>
</DotNetCliToolReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet">
<Version>1.0.0-msbuild1-final</Version>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools">
<Version>1.0.0-msbuild1-final</Version>
</PackageReference>
The CLI-reference will show up as missing in solution explorer (at least for me) and dont remove it since the reference will be removed.
Great that works :).. did u have issues with AddUserSecrets? it pops up with parameter less error for ApplicationDBContext but EF works as it should when I comment that.
Havent used that tool. Can check during the day if i can get it to work. What version are you using?
it seems, what i came across is a know issue (https://stackoverflow.com/questions/40858155/ef-core-1-1-to-webapi-core-add-migration-fails) not related to EF. using the dotnet preview 3 with 1.1 runtime
For EntityFrameworkCore 2.0, I added the following line similar to what bricelam told above. It worked fine.
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.0-msbuild1-final"/>
But, It will show-up a warning. Thats ok.
warning NU1603: DotnetCliToolReference-Microsoft.EntityFrameworkCore.Tools.DotNet depends on Microsoft.EntityFrameworkCore.Tools.DotNet (>= 2.0.0-msbuild1-final) but Microsoft.EntityFrameworkCore.Tools.DotNet 2.0.0-msbuild1-final was not found. An approximate best match of Microsoft.EntityFrameworkCore.Tools.DotNet 2.0.0-preview1-final was resolved.
Thanks!
@technicalganesh - The package version is 2.0.0 (aligned with other EF Core packages) instead of 2.0.0-msbuild1-final.
If you are using Visual Studio 2017, actually you dont need "Microsoft.EntityFrameworkCore.Tools.DotNet"
instead of it install the "Microsoft.VisualStudio.Web.CodeGeneration.Design"
From Tools > NuGet Package Manager > Package Manager Console Run the following command
Install-Package Microsoft.VisualStudio.Web.CodeGeneration.Design
Most helpful comment
For preview3 (csproj-based) tooling, you'll need to add the following.