Scaffold-DbContext can name namespace wrong if phrase with space is used on OutputDir
See original GitHub issueScaffold-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:
- Created 2 years ago
- Comments:6 (5 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Yes, I’m OK with this approach. It would also be nice to do it for Migration class names.
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.