Views not being created

Mar 19, 2011 at 5:24 PM

Following Steve's introductory post of 2011-01-13, I create a simple class called Driver in a brand new MVC3 project...

    public class Driver
    {
        public int DriverId { getset; }
        [Requiredpublic string LicenseNumber { getset; }
        public string Name { getset; }
        public DateTime LicenseDate { getset; }
        public DateTime BirthDate { getset; }
        public string Address1 { getset; }
        public string Address2 { getset; }
        public string City { getset; }
        public string State { getset; }
        public string Zipcode { getset; }
    }

I then used 'Scaffold Controller Driver' which created the DriversController but then fell over on all the view stuff. My environment is VS2010 with SP1 (released a week ago), NuGet 1.1 and the following packages installed:

<packages>
  <package id="EntityFramework" version="4.1.10311.0" />
  <package id="SqlServerCompact" version="4.0.8482.1" />
  <package id="T4Scaffolding" version="0.9.7" />
  <package id="MvcScaffolding" version="0.9.7" />
  <package id="EFCodeFirst" version="1.0" />
</packages>

The following errors occurred:

PM> Scaffold Controller Driver
Scaffolding DriversController...
Added controller 'Controllers\DriversController.cs'
Added database context 'Models\SPTSWebContext.cs'
Added 'Drivers' to database context 'Models\SPTSWebContext.cs'
Invoke-Scaffolder : A parameter cannot be found that matches parameter name 'Controller'.
At C:\Users\John\Documents\SPTS\packages\MvcScaffolding.0.9.7\tools\Views\MvcScaffolding.Views.ps1:18 char:38
+     Scaffold $ViewScaffolder -Controller <<<<  $Controller -ViewName $_ -ModelType $ModelType -Template $_ -Area $Area -Layout $Layout -SectionNames $SectionNames -PrimarySectionName $PrimarySectionName -ReferenceScr
iptLibraries:$ReferenceScriptLibraries -Project $Project -CodeLanguage $CodeLanguage -OverrideTemplateFolders $TemplateFolders -Force:$Force -BlockUi
    + CategoryInfo          : InvalidArgument: (:) [Invoke-Scaffolder], ParameterBindingException
    + FullyQualifiedErrorId : NamedParameterNotFound,T4Scaffolding.Cmdlets.InvokeScaffolderCmdlet
 
Invoke-Scaffolder : A parameter cannot be found that matches parameter name 'Controller'.
At C:\Users\John\Documents\SPTS\packages\MvcScaffolding.0.9.7\tools\Views\MvcScaffolding.Views.ps1:18 char:38
+     Scaffold $ViewScaffolder -Controller <<<<  $Controller -ViewName $_ -ModelType $ModelType -Template $_ -Area $Area -Layout $Layout -SectionNames $SectionNames -PrimarySectionName $PrimarySectionName -ReferenceScr
iptLibraries:$ReferenceScriptLibraries -Project $Project -CodeLanguage $CodeLanguage -OverrideTemplateFolders $TemplateFolders -Force:$Force -BlockUi
    + CategoryInfo          : InvalidArgument: (:) [Invoke-Scaffolder], ParameterBindingException
    + FullyQualifiedErrorId : NamedParameterNotFound,T4Scaffolding.Cmdlets.InvokeScaffolderCmdlet
 
Invoke-Scaffolder : A parameter cannot be found that matches parameter name 'Controller'.
At C:\Users\John\Documents\SPTS\packages\MvcScaffolding.0.9.7\tools\Views\MvcScaffolding.Views.ps1:18 char:38
+     Scaffold $ViewScaffolder -Controller <<<<  $Controller -ViewName $_ -ModelType $ModelType -Template $_ -Area $Area -Layout $Layout -SectionNames $SectionNames -PrimarySectionName $PrimarySectionName -ReferenceScr
iptLibraries:$ReferenceScriptLibraries -Project $Project -CodeLanguage $CodeLanguage -OverrideTemplateFolders $TemplateFolders -Force:$Force -BlockUi
    + CategoryInfo          : InvalidArgument: (:) [Invoke-Scaffolder], ParameterBindingException
    + FullyQualifiedErrorId : NamedParameterNotFound,T4Scaffolding.Cmdlets.InvokeScaffolderCmdlet
 
Invoke-Scaffolder : A parameter cannot be found that matches parameter name 'Controller'.
At C:\Users\John\Documents\SPTS\packages\MvcScaffolding.0.9.7\tools\Views\MvcScaffolding.Views.ps1:18 char:38
+     Scaffold $ViewScaffolder -Controller <<<<  $Controller -ViewName $_ -ModelType $ModelType -Template $_ -Area $Area -Layout $Layout -SectionNames $SectionNames -PrimarySectionName $PrimarySectionName -ReferenceScr
iptLibraries:$ReferenceScriptLibraries -Project $Project -CodeLanguage $CodeLanguage -OverrideTemplateFolders $TemplateFolders -Force:$Force -BlockUi
    + CategoryInfo          : InvalidArgument: (:) [Invoke-Scaffolder], ParameterBindingException
    + FullyQualifiedErrorId : NamedParameterNotFound,T4Scaffolding.Cmdlets.InvokeScaffolderCmdlet
 
Invoke-Scaffolder : A parameter cannot be found that matches parameter name 'Controller'.
At C:\Users\John\Documents\SPTS\packages\MvcScaffolding.0.9.7\tools\Views\MvcScaffolding.Views.ps1:18 char:38
+     Scaffold $ViewScaffolder -Controller <<<<  $Controller -ViewName $_ -ModelType $ModelType -Template $_ -Area $Area -Layout $Layout -SectionNames $SectionNames -PrimarySectionName $PrimarySectionName -ReferenceScr
iptLibraries:$ReferenceScriptLibraries -Project $Project -CodeLanguage $CodeLanguage -OverrideTemplateFolders $TemplateFolders -Force:$Force -BlockUi
    + CategoryInfo          : InvalidArgument: (:) [Invoke-Scaffolder], ParameterBindingException
    + FullyQualifiedErrorId : NamedParameterNotFound,T4Scaffolding.Cmdlets.InvokeScaffolderCmdlet
 
Invoke-Scaffolder : A parameter cannot be found that matches parameter name 'Controller'.
At C:\Users\John\Documents\SPTS\packages\MvcScaffolding.0.9.7\tools\Views\MvcScaffolding.Views.ps1:18 char:38
+     Scaffold $ViewScaffolder -Controller <<<<  $Controller -ViewName $_ -ModelType $ModelType -Template $_ -Area $Area -Layout $Layout -SectionNames $SectionNames -PrimarySectionName $PrimarySectionName -ReferenceScr
iptLibraries:$ReferenceScriptLibraries -Project $Project -CodeLanguage $CodeLanguage -OverrideTemplateFolders $TemplateFolders -Force:$Force -BlockUi
    + CategoryInfo          : InvalidArgument: (:) [Invoke-Scaffolder], ParameterBindingException
    + FullyQualifiedErrorId : NamedParameterNotFound,T4Scaffolding.Cmdlets.InvokeScaffolderCmdlet
 
PM> 
Mar 27, 2011 at 2:16 PM

I have the exact same issue

Mar 27, 2011 at 2:31 PM

 

Mine is happening on version 0.9.8
Mar 28, 2011 at 2:38 AM

I did get it to work a couple of days ago - here's how. I had a modeling project in the solution so I started a brand new solution with just the ASP.NET MVC 3 web project. I grabbed the latest source code since Steve had updated it the day before (Tues. I think). I Installed EntityFramework first (just released packaged) then installed MvcScaffolding from my local build. I then created a simple model class and tried 'Scaffold Controller Driver' (Driver is my model class) and it worked, including creating the views. Using the -Repository also works as does using EntityFramework.SqlServerCompact. So I think it's "real close now" to being stable and usable.

Mar 28, 2011 at 10:26 PM
Edited Mar 28, 2011 at 11:31 PM

I was able to start a new project and get it working. Though there was nothing unusual with my previous project, and I tried to figure out what this issue could be and couldn't track it down.

Mar 29, 2011 at 7:06 AM

I'm seeing a very similar error in version 0.9.8 just downloaded today and run in an almost new project. It appears as though it is not reading the parameters of the command correctly but doesn't spell out how to properly do it. The end result is that the views are created, the controller appears to be created, but the Repository Class doesn't... Here's what I get when running the command to generate the Scaffolding.

 

PM> Scaffold Controller Announcement -Repository -Force
Scaffolding AnnouncementsController...
Invoke-Scaffolder : A parameter cannot be found that matches parameter name 'ModelType'.
At c:\users\greg\documents\visual studio 2010\Projects\packages\MvcScaffolding.0.9.8\tools\Controller\MvcScaffolding.Controller.ps1:64 char:33
+         Scaffold Repository -ModelType <<<<  $foundModelType.FullName -DbContextType $DbContextType -Area $Area -Project $Project -CodeLanguage $CodeLanguage -Force:$Force -BlockUi
    + CategoryInfo          : InvalidArgument: (:) [Invoke-Scaffolder], ParameterBindingException
    + FullyQualifiedErrorId : NamedParameterNotFound,T4Scaffolding.Cmdlets.InvokeScaffolderCmdlet
 
Added controller Controllers\AnnouncementsController.cs
Added Create view at 'Views\Announcements\Create.cshtml'
Added Edit view at 'Views\Announcements\Edit.cshtml'
Added Delete view at 'Views\Announcements\Delete.cshtml'
Added Details view at 'Views\Announcements\Details.cshtml'
Added Index view at 'Views\Announcements\Index.cshtml'
Added _CreateOrEdit view at 'Views\Announcements\_CreateOrEdit.cshtml'
PM>

The project then won't compile because the interface model (IAnnouncementRepository) isn't there.

Coordinator
Apr 1, 2011 at 3:58 PM

This is usually caused by having an incomplete installation. Try running "Get-Scaffolder" and check you have all the expected scaffolders (e.g., for controller, view, repository, dbcontext, etc), and also run "Get-DefaultScaffolder" and check there are entries for controller, view, repository, dbcontext, etc.

If something appears to be missing:

1. Uninstall MvcScaffolding and T4Scaffolding

2. Close then reopen Visual Studio 

3. Reinstall MvcScaffolding

If you can reproduce this issue, i.e., you know what sequence of actions got your project into this state, please let me know so I can fix the underlying cause! Thanks

Apr 10, 2011 at 4:21 AM

Hi Steve

I tried every permutation and combination and none worked.   I created new emtpy MVC 3.0 project about 10 times but nothing worked. 

if I try this then I get this

PM> Install-Package MvcScaffolding

'EntityFramework 4.1.10311.0' already installed.

'T4Scaffolding 0.9.9' already installed.

'MvcScaffolding 0.9.9' already installed.

Successfully added 'EntityFramework 4.1.10311.0' to PlumDish.Website.

Successfully added 'T4Scaffolding 0.9.9' to PlumDish.Website.

Successfully added 'MvcScaffolding 0.9.9' to PlumDish.Website.

Install-Package : Exception calling "EnumerateFiles" with "3" argument(s): "The path is not of a legal form."

At line:1 char:16

+ Install-Package <<<< MvcScaffolding

+ CategoryInfo : NotSpecified: (:) [Install-Package], CmdletInvocationException

+ FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.Cmdlets.InstallPackageCmdlet

I get pretty much same result creating in this order as well

Install-Package EntityFramework

Install-Package T4Scaffolding

Install-Package MvcScaffolding

 

 This is drving me nuts.  Am I missing something?

 

May 12, 2011 at 12:17 AM

I have been having this same issue.

Following the suggestions Steve made above has resolved my issues

1. Uninstall MvcScaffolding and T4Scaffolding

2. Close then reopen Visual Studio 

3. Reinstall MvcScaffolding

 

-MARK-

Jun 9, 2011 at 5:29 PM
Edited Jun 9, 2011 at 5:31 PM

This issue is still appearing in 1.0.0

The "InferPreferredViewEngine" function in install.ps1 is a bit wonky. It's throwing the "path is not of a legal form" exception - though I'm not sure the conditions under which it does so.

This results in no default scaffolder having been set for views, causing Scaffold Controller [Blah] to go a rather spacky.

("Invoke-Scaffolder : A parameter cannot be found that matches parameter name 'Controller'.")

In the short-term, you can fix it yourself for your solution:-

"Set-DefaultScaffolder -Name View -Scaffolder MvcScaffolding.AspxView -SolutionWide" (or similar for Razor)

- but in the medium term, we should revisit that function and figure out why it's throwing exceptions.

Jun 19, 2011 at 1:57 PM

Same issue in Version 1.0.0 Following Steve reccomened steps above resolved my Issue.

 

1. Uninstall MvcScaffolding and T4Scaffolding

2. Close then reopen Visual Studio�

3. Reinstall MvcScaffolding

putrtek