I've installed Visual Studio for Mac (OSX 10.12.1) today and I've been diving in quite extensively.
I wanted to try to get EntityFrameworkCore (1.1.0) to run with SQLite.
So I've created a new Console Application .NET Core and with some troubles been able to add all the necessary nuget packages. Somehow Visual Studio was not able to download the dependencies, so I had to download every dependency manually. (Maybe this solves the problem: .Net Core 1.1.0 NuGet packages fail to install in Visual Studio Mac haven't testet this yet.)
As stated in this article (https://docs.microsoft.com/en-us/ef/core/get-started/netcore/new-db-sqlite) I wanted to add the migration, but I couldn't find the necessary command line tool in the IDE. Did I miss something here?
Then I went on to use the .NET Core CLI to do it manually via. console. ( https://www.microsoft.com/net/core#macos). But when I execute
dotnet ef migrations add init I get the following error.
No executable found matching command "dotnet-ef"
Was anyone able to get this to run successfully?
Visual Studio for Mac 2017 currently (April 2017) does not support adding a reference to
Microsoft.EntityFrameworkCore.Tools.DotNet and returns an error:
Package 'Microsoft.EntityFrameworkCore.Tools.DotNet 1.0.0' has a package type 'DotnetCliTool' that is not supported by project 'MacMvc'.
You can edit the file manually and add the reference directly to the
csproj file, as documented. Add this to your csproj file:
<ItemGroup> <DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="1.0.0" /> </ItemGroup>
dotnet restore to install the package. After that, you will be able to use
dotnet ef migrations add NameOfMigration and
dotnet ef database update scripts as per documentation.
N.B.: you must be in the project directory when executing commands.
Also see suggestion feeedback for VS 2017 for Mac:
Using VS for Mac, adding those following lines into .csproj makes the migration work for me:
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="1.1.1" /> <DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="1.0.0-msbuild2-final" />
Packages will be automatically restored saving the .csproj from VS.
To run the "dotnet ef" command through the terminal, you need to be in the project directory, I mean not from the directory where the .sln file is, but from the lower level.
Note: Same trick with v1.0.1 of Tools.DotNet didn't work, I do not know why.