1
votes

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)
1
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
@Nikolaus You are right my friend. Thanks! - wltz
An accepted answer would be nice. ;-) - Nikolaus

1 Answers

4
votes

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

-UseDatabaseNames

not

—use-database-names