'VSCode on M1 Mac wont run "dotnet ef" command in Terminal
I am not sure if EFCore is supposed to work for M1 Mac being in 6.0.0 preview version. I was doing a udemy course and came to a stop where I was not able to run "dotnet ef" command in Terminal to do migrations.
me@my-MBP-2 dotnet-rpg % dotnet tool update --global dotnet-ef
Tool 'dotnet-ef' was reinstalled with the latest stable version (version '5.0.8').
me@my-MBP-2 dotnet-rpg % dotnet ef -h
me@my-MBP-2 dotnet-rpg %
I tried to update all the EFCore packages to 6.0.0 version thinking that my resolve but still no go.
Here's my .csproj file.
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<RootNamespace>dotnet_rpg</RootNamespace>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="8.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="5.0.8" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="5.0.8" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.0-preview.6.21352.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.0-preview.6.21352.1">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.0-preview.6.21352.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="6.0.0-preview.6.21352.1">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.1.4" />
</ItemGroup>
</Project>
Can you suggest if I am doing something wrong ?
Solution 1:[1]
Here is the issue: https://github.com/dotnet/efcore/issues/25927
You can install dotnet-ef locally as a solution:
dotnet new tool-manifest # if you are setting up this repo
dotnet tool install --local dotnet-ef --version 6.0.0-rc.2.21480.5
Solution 2:[2]
You can try uninstalling the previous dotnet-ef and install again.
dotnet tool uninstall dotnet-ef --global
dotnet tool install dotnet-ef --global -a arm64
this is only valid for M1 chip MacBooks.This will make it running dotnet ef commands.
Solution 3:[3]
I've ran into the same issue and it appears that dotnet ef is not working on M1 processors yet.
For my project I had to generate migrations scripts by checking out my working branch on Windows machine and run the same command (with same dotnet versions) successfully.
On Parallels with Windows 11 I can not get dotnet tool to work (exceptions thrown) and can not test it out properly.
Updated:
I've found a solution on github which solved the issue on M1 Mac.
The dotnet ef tool has to be signed manually with command:
codesign -s - ~/.dotnet/tools/dotnet-ef
More details can be found here: https://github.com/dotnet/efcore/issues/25927#issuecomment-942198498
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | tdy |
| Solution 2 | Arda Çetinkaya |
| Solution 3 |
