1

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?

Colin
  • 22,328
  • 17
  • 103
  • 197
  • Have you gone to line 89 char 122 on file MvcScaffolding.Controller.ps1? – Botonomous Sep 26 '13 at 13:31
  • Its the call to `GetDirectoryName`. Something wrong with what's in `$outputPath` – Colin Sep 26 '13 at 14:04
  • There's a line that sets it `$outputPath = Join-Path Controllers $ControllerName` but "Controllers" comes from nowhere I can see. Don't know anything about programming or debugging T4 templates I'm afraid – Colin Sep 26 '13 at 14:20

0 Answers0