Problem with "dotnet ef dbcontext scaffold" on Linux Bash bash entity-framework-core


while issuing following command in linux bash,

dotnet ef dbcontext scaffold "Server=\MSSQLSERVER2017;Database=TestDb;User Id=test;Password=test@987" Microsoft.EntityFrameworkCore.SqlServer -o Models --context AppDbContext -t solid

I get this error message:

Unrecognized command or argument 'Microsoft.EntityFrameworkCore.SqlServer'

I figured out the problem that it is being caused by space in "User Id" in the command because when i remove space i get this message.

Keyword not supported: 'userid'

I tried lots of combinations like putting User\ Id, 'User Id', "User Id", User" "Id and a lot more I found on the internet but I am still stuck on this. How can I solve this?

My EF version:

Entity Framework Core .NET Command-line Tools

My dotnet version:

.NET Core SDK (reflecting any global.json):
 Version:   2.1.500
 Commit:    b68b931422

Runtime Environment:
OS Name:     arch
OS Version:  
OS Platform: Linux
RID:         arch-x64
Base Path:   /opt/dotnet/sdk/2.1.500/

Host (useful for support):
Version: 2.1.6
Commit:  3f4f8eebd8

.NET Core SDKs installed:
 2.1.500 [/opt/dotnet/sdk]

.NET Core runtimes installed:
Microsoft.NETCore.App 2.1.6 [/opt/dotnet/shared/Microsoft.NETCore.App]

P.S. I've already added "Microsoft.EntityFrameworkCore.Design" package in the project too.

11/21/2018 5:36:47 AM

Popular Answer

I also had this same issue on Windows. dotnet ef scaffold error

but i fixed it by using the Command below.

> dotnet ef dbcontext scaffold "Server=.\;Database=YourDatabase;Trusted_Connection=False; User ID=sa; Password=YourPassword;" Microsoft.EntityFrameworkCore.SqlServer -o Model -c "YourDBContext"

In my own case, i tried to figure our what was wrong with my previous command and i got some few answers though they might not be applicable to everyone.

  1. Before the "Server" key, i was using a single quote so i changed it to double quote.
  2. In my the "." for the server name, i included backslash "\"
  3. I enclosed my db context with a double quote.

Although i took all this steps but the truth is that i don't know which one actually worked but i can assure you that the above code works pretty well. However you can checkout an article i found below.

3/29/2019 10:34:07 AM

Related Questions


Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow