I have installed MvcScaffolding without any issues but when I try to execute a scaffold request I get the error "DbContext.Task.t4" does not exist along with other files that are missing. I have a model called Task which I think its referring to but I am at a loss on how I fix this error?
"Scaffold Controller Task -ModelType Task -ControllerName TasksController -DbContextType TasksDbContext"
Install-Package MvcScaffolding
- PM> Install-Package MvcScaffolding
- Attempting to resolve dependency 'T4Scaffolding (≥ 1.0.2)'.
- Attempting to resolve dependency 'EntityFramework (≥ 4.1.10311.0)'.
- Successfully installed 'MvcScaffolding 1.0.2'.
- Successfully added 'MvcScaffolding 1.0.2' to MvcApplication1.
Error
- PM> Scaffold Controller Task -ModelType Task -ControllerName TasksController -DbContextType TasksDbContext
Scaffolding TasksController...
Find-ScaffolderTemplate : Could not find template 'DbContext.Task.t4' below folders ['C:\Development\MVCPLTaskmanager\MvcApplication1\packages\T4Scaffolding.1 .0.2\tools\EFDbContext'] At line:1 char:23 + param($c, $a) return . <<<< $c @a + CategoryInfo : NotSpecified: (:) [Find-ScaffolderTemplate], Exception + FullyQualifiedErrorId : T4Scaffolding.Cmdlets.FindScaffolderTemplateCmdlet
Get-ProjectType : Cannot find a type matching the name 'MvcApplication1.Models.TasksDbContext'. Try specifying the fully-qualified type name, including namesp ace. At C:\Development\MVCPLTaskmanager\MvcApplication1\packages\T4Scaffolding.1.0.2\tools\EFDbContext\T4Scaffolding.EFDbContext.ps1:45 char:39 + $foundDbContextType = Get-ProjectType <<<< ($dbContextNamespace + "." + $DbContextType) -Project $Project + CategoryInfo : NotSpecified: (:) [Get-ProjectType], InvalidOperationException + FullyQualifiedErrorId : T4Scaffolding.Cmdlets.GetProjectTypeCmdlet
Invoke-Scaffolder : Created database context TasksDbContext, but could not find it as a project item At C:\Development\MVCPLTaskmanager\MvcApplication1\packages\MvcScaffolding.1.0.2\tools\Controller\MvcScaffolding.Controller.ps1:71 char:40 + $dbContextScaffolderResult = Scaffold <<<< DbContext -ModelType $foundModelType.FullName -DbContextType $DbContextType -Area $Area -Project $Projec t -CodeLanguage $CodeLanguage -BlockUi + CategoryInfo : NotSpecified: (:) [Invoke-Scaffolder], RuntimeException + FullyQualifiedErrorId : T4Scaffolding.Cmdlets.InvokeScaffolderCmdlet
ANSWER It turns out that my model's namespace needs to be the same as the MVC project. Once I changed the namespace the scaffolding worked.