Scaffolding: Don't use "GeneratedCode" directory as part of the namespace
- Dominant language
- C#
- Stars
- 14.8k
- Forks
- 3.4k
- PR merge metrics
- PR metrics pending
Description
One common pattern when working with an existing database is to put all of the scaffolded code into a directory named `GeneratedCode`. This lets developers know that the files shouldn't be edited directly because they may be re-generated in the future. The scaffolded code is then augmented with business logic, etc. with partial classes outside of the GeneratedCode directory.
It's easy enough to generate code into a directory like this using the `--output-dir` option:
```cmd
dotnet ef dbcontext scaffold ... --output-dir Models\GeneratedCode
```
Unfortunately, the directory is also used when determining the namespace, so you end up with classes in the `MyApp.Models.GeneratedCode` namespace. You can compensate for this by using the `--namespace` option.
Since this is a common enough pattern, we should probably just ignore any directories named `GeneratedCode` when determining the namespace. This means that users wouldn't have to specify the `--namespace` option, and classes would be generated inside `MyApp.Models` for the example above.
Contributor guide
Assessment
This issue has not been assessed yet.