question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Scaffold-DbContext can name namespace wrong if phrase with space is used on OutputDir

See original GitHub issue

Scaffold-DbContext is naming namespace wrong if -OutputDir is filled with phrase containing space.

For example: Example Folder OutputDir makes namespace ConsoleApp.Example Folder, what is wrong for naming namespaces and can’t be builded. It should be ConsoleApp.Example_Folder.

Code

I made command through PMC like this:

Scaffold-DbContext "connectionString" MySql.EntityFrameworkCore -Tables some_tables_here -OutputDir "Example Folder" -Force

Command is working, but output classes and context have wrong namespace.

Include provider and version information

EF Core version: 5.0 Database provider: MySql.EntityFrameworkCore Target framework: NET 5.0 Operating system: IDE: Visual Studio 2019 16.9.3

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
bricelamcommented, Oct 18, 2021

Yes, I’m OK with this approach. It would also be nice to do it for Migration class names.

0reactions
mees-commented, Oct 22, 2021

I encountered the same issue when using a dash “-” in the output directory name. All the namespaces get invalid names and the classes wont build.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Scaffold-DbContext to different output folder
As the top answer indicates, if you want a different folder within that project, you can just use the -OutputDir option.
Read more >
Scaffolding (Reverse Engineering) - EF Core
The entity classes and a DbContext class are scaffolded into the project's root directory and use the project's default namespace. .NET CLI ...
Read more >
EF Core tools reference (Package Manager Console)
The DbContext class to use. Class name only or fully qualified with namespaces. If this parameter is omitted, EF Core finds the context...
Read more >
Apps and Services with .NET 7
If a table or column name contains spaces, then you must surround the name in square brackets like [Order Details] . The SQL...
Read more >
Introduction to ASP.NET Core
With ASP.NET Core, you can: Build web apps and services, IoT apps, and mobile backends. Use your favorite development tools on Windows, macOS,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found