I have my DbContext class in the same folder and namespace as my Models (MvcApplication.Models
). I thought it would be better to put it in the folder and namespace where my repositories are (MvcApplication.Data
). I did that, the code compiles and runs, but then I tried to scaffold a controller. I got this error:
Exception calling "GetDirectoryName" with "1" argument(s): "Illegal characters in path."
At C::\....\MvcScaffolding.1.0.9\tools\Controller\MvcScaffolding.Controller.ps1:89 char:122
This is line 89:
$controllerNamespace = [T4Scaffolding.Namespaces]::Normalize($defaultNamespace + "." + [System.IO.Path]::GetDirectoryName($outputPath).Replace([System.IO.Path]::DirectorySeparatorChar, "."))
So I moved it back and the scaffolder works again. Can I fix the scaffolder to let me move the DbContext?
Maybe the data layer is the wrong place for it anyway? I put some custom sql in the SaveChanges override but maybe that was breaking an unwritten rule. Maybe the sql should move and the DbContext should stay with the Models?