3

I am trying to create the model from existing DB using EntityFramework Core, database first approach. The model was created, but the table name and column name were changed to C# style. Because I want the model still using exact table name and column name as in the database, so I append the "--use-database-names" in the command line, according to Entity Framework Core tools reference

Following is the command executed in the Package Manager Console:

Scaffold-DbContext "Server=aServer;Database=someDb;Trusted_Connection=True" Microsoft.EntityFrameworkCore.SqlServer -o Models --use-database-names

But I got following error:

Scaffold-DbContext : A positional parameter cannot be found that accepts argument '--use-database-names'. At line:1 char:1

  • Scaffold-DbContext "Server=aServer;Database=someDb;Trusted_Conn ...
  • ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    • CategoryInfo : InvalidArgument: (:) [Scaffold-DbContext], ParameterBindingException
    • FullyQualifiedErrorId : PositionalParameterNotFound,Scaffold-DbContext

Has anybody encounter this issue? Did I miss something? Thanks in advance!

Following are some basic info of the simple project.

IDE: Visual Studio 2017

Target framework: .NET Core 2.1

Installed NuGet Package:

Microsoft.EntityFrameworkCore.Design(2.2.0)
Microsoft.EntityFrameworkCore.SqlServer(2.2.0)
Microsoft.EntityFrameworkCore.Tools(2.2.0)
Microsoft.EntityFrameworkCore.SqlServer.Design(1.1.6)
wltz
  • 621
  • 1
  • 11
  • 22
  • 2
    The tools reference you linked to describes the use of the .netCore cli. You mentioned, you use Package Manager Console. Some Parameters have to be written differently in PMC than in Cli. – Nikolaus Dec 06 '18 at 22:18
  • @Nikolaus You are right my friend. Thanks! – wltz Dec 07 '18 at 15:30
  • An accepted answer would be nice. ;-) – Nikolaus Dec 11 '18 at 00:05

1 Answers1

6

Like in the reference for Package Manager Console mentioned, you have to write:

-UseDatabaseNames

not

—use-database-names
Nikolaus
  • 1,859
  • 1
  • 10
  • 16