Efcore: Database first approach on MacOS

Created on 24 Jun 2020  路  10Comments  路  Source: dotnet/efcore

I am trying to map database to objects in my application on macOS Catalina.

Using terminal i typed

sudo dotnet ef dbcontext scaffold

and the result is:

System.ComponentModel.Win32Exception (1): Operation not permitted
at System.Diagnostics.Process.ForkAndExecProcess(String filename, String[] argv, String[] envp, String cwd, Boolean redirectStdin, Boolean redirectStdout, Boolean redirectStderr, Boolean setCredentials, UInt32 userId, UInt32 groupId, UInt32[] groups, Int32& stdinFd, Int32& stdoutFd, Int32& stderrFd, Boolean usesTerminal, Boolean throwOnNoExec)
at System.Diagnostics.Process.StartCore(ProcessStartInfo startInfo)
at System.Diagnostics.Process.Start()
at System.Diagnostics.Process.Start(ProcessStartInfo startInfo)
at Microsoft.EntityFrameworkCore.Tools.Exe.Run(String executable, IReadOnlyList`1 args, String workingDirectory, Boolean interceptOutput)
at Microsoft.EntityFrameworkCore.Tools.Project.FromFile(String file, String buildExtensionsDir, String framework, String configuration, String runtime)
at Microsoft.EntityFrameworkCore.Tools.RootCommand.Execute()
at Microsoft.EntityFrameworkCore.Tools.Commands.CommandBase.<>c__DisplayClass0_0.b__0()
at Microsoft.DotNet.Cli.CommandLine.CommandLineApplication.Execute(String[] args)
at Microsoft.EntityFrameworkCore.Tools.Program.Main(String[] args)
Operation not permitted

I added full disk access to the terminal and Visual Studio Code, but without success.

closed-question customer-reported

All 10 comments

What happens when you try to do the above without sudo? Scaffold a database typically isn't supposed to require root access.

I know, but when I type it without sudo the result is:

System.ComponentModel.Win32Exception (13): Permission denied
at System.Diagnostics.Process.ForkAndExecProcess(String filename, String[] argv, String[] envp, String cwd, Boolean redirectStdin, Boolean redirectStdout, Boolean redirectStderr, Boolean setCredentials, UInt32 userId, UInt32 groupId, UInt32[] groups, Int32& stdinFd, Int32& stdoutFd, Int32& stderrFd, Boolean usesTerminal, Boolean throwOnNoExec)
at System.Diagnostics.Process.StartCore(ProcessStartInfo startInfo)
at System.Diagnostics.Process.Start()
at System.Diagnostics.Process.Start(ProcessStartInfo startInfo)
at Microsoft.EntityFrameworkCore.Tools.Exe.Run(String executable, IReadOnlyList`1 args, String workingDirectory, Boolean interceptOutput)
at Microsoft.EntityFrameworkCore.Tools.Project.FromFile(String file, String buildExtensionsDir, String framework, String configuration, String runtime)
at Microsoft.EntityFrameworkCore.Tools.RootCommand.Execute()
at Microsoft.EntityFrameworkCore.Tools.Commands.CommandBase.<>c__DisplayClass0_0.b__0()
at Microsoft.DotNet.Cli.CommandLine.CommandLineApplication.Execute(String[] args)
at Microsoft.EntityFrameworkCore.Tools.Program.Main(String[] args)
Permission denied

That sounds like you have some sort of setup problem with the EF tools, that won't be solved by using sudo. Try uninstalling and reinstalling the tools (dotnet tool uninstall -g dotnet-ef; dotnet tool install -g dotnet-ef).

If you still run into issues, you may want to look at the dotnet-ef.exe itself which is executed, you should be able to find this under ~/.nuget/packages/dotnet-ef/<version>/tools/netcoreapp3.1/any.

It didn't help. I also tried to find this file, but the folder dotnet-ef doesn't exist in ~/.nuget/packages/.

There are just:

drwxr-xr-x 4 marmited staff 128 25 cze 10:46 .
drwxr-xr-x 17 marmited staff 544 24 cze 21:48 ..
drwxr-xr-x 4 marmited staff 128 25 cze 10:46 .store
-rwxr-xr-x 1 marmited staff 85116 25 cze 10:46 dotnet-ef

Not sure how things are set up on macos - on Linux, nuget packages (including global tools) are found under ~/.nuget/packages.

What is the directory whose contents you list above (with the dotnet-ef file)?

Not sure how things are set up on macos - on Linux, nuget packages (including global tools) are found under ~/.nuget/packages.

What is the directory whose contents you list above (with the dotnet-ef file)?

I found a lot of packages inside ~/.nuget/packages/, but without dotnet-ef folder
for example:

...
drwxr-xr-x 4 marmited staff 128 28 maj 19:34 microsoft.dotnet.platformabstractions
drwxr-xr-x 7 marmited staff 224 24 cze 20:48 microsoft.entityframeworkcore
drwxr-xr-x 7 marmited staff 224 24 cze 20:48 microsoft.entityframeworkcore.abstractions
drwxr-xr-x 7 marmited staff 224 24 cze 20:48 microsoft.entityframeworkcore.analyzers
drwxr-xr-x 5 marmited staff 160 7 cze 01:50 microsoft.entityframeworkcore.design
drwxr-xr-x 7 marmited staff 224 24 cze 20:48 microsoft.entityframeworkcore.relational
drwxr-xr-x 4 marmited staff 128 28 maj 19:34 microsoft.entityframeworkcore.sqlite
drwxr-xr-x 4 marmited staff 128 28 maj 19:34 microsoft.entityframeworkcore.sqlite.core
drwxr-xr-x 4 marmited staff 128 24 cze 20:48 microsoft.entityframeworkcore.sqlserver
drwxr-xr-x 5 marmited staff 160 7 cze 01:50 microsoft.entityframeworkcore.tools
...

In the previous post I pasted contents of /Users/marmited/.dotnet/tools.

@marmited you probably want to check out @smitpatel's posted issue above (https://github.com/dotnet/sdk/issues/10237), there seems to be an issue if your homedir (with .dotnet and .nuget) isn't on a local physical drive, etc.

@roji I checked this post but it didn't helped. Everything is just on ma local physical drive. I don't have any external drive.

Finally, I solved my issue. I don't know why but inside my project was 'dotnet' file. After removing it everything works fine!

Was this page helpful?
0 / 5 - 0 ratings