简体   繁体   English

使用C#在ASP.NET MVC 4中脚手架控制器时出错

[英]Error when scaffolding controller in asp.net mvc 4 with c#

I get the following error when scaffolding the model 'Sender'. 搭建模型“发件人”时出现以下错误。 The sender model is in a class library project called BmbMessenger.Data and this project's dll is referenced in BmbMessenger.AccountManager but for some reason the 'Sender' model cannot be referenced to enable scaffolding run properly. 发件人模型位于名为BmbMessenger.Data的类库项目中,并且在BmbMessenger.AccountManager中引用了该项目的dll,但由于某些原因,无法引用“发件人”模型来使脚手架正常运行。 I also tried using the gui scaffolding tool but to no avail. 我也尝试使用gui脚手架工具,但无济于事。 I confused as to why the scaffolding is not working. 我对为什么脚手架不起作用感到困惑。

Scaffold Controller Switch -DbContextType BmbMessengerContext -Verbose -Repository -Project BmbMessenger.AccountManager -ModelType Switch
Get-ProjectType : Cannot find a type matching the name 'Switch'. Try specifying the fully-qualified type name, including namespace.
At C:\Users\Andrew\Documents\Visual Studio 2012\Projects\BmbMessenger\packages\MvcScaffolding.1.0.9\tools\Controller\MvcScaffolding.Controller.ps1:50 char:35
+     $foundModelType = Get-ProjectType <<<<  $ModelType -Project $Project
    + CategoryInfo          : NotSpecified: (:) [Get-ProjectType], InvalidOperationException
    + FullyQualifiedErrorId : T4Scaffolding.Cmdlets.GetProjectTypeCmdlet

As you add a new model, change your model, or import an existing model, you should first build your project and then try to use the .tt entity classes as models for scaffolding. 添加新模型,更改模型或导入现有模型时,应首先构建项目,然后尝试将.tt实体类用作脚手架模型。

Hope that helps 希望能有所帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM