具有 Mvc5、EF6、VisualStudio 2013 中存储库的脚手架控制器 [英] Scaffolding controllers with repositories in Mvc5, EF6, VisualStudio 2013

本文介绍了具有 Mvc5、EF6、VisualStudio 2013 中存储库的脚手架控制器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 vs2012 中,我曾经使用 Steve Sanderson 的 mvcScaffolding Package 这个包我可以用单元测试搭建动作方法以及具有存储库和依赖项注入的控制器.我的问题很简单.在 vs2013 中有没有办法做到这一点?当我在 vs2013 中安装软件包时,出现以下错误:

In vs2012 I used to use Steve Sanderson's mvcScaffolding Package with this package I could scaffold Action Methods with unit tests and controllers with repositories and dependency injection. My question is simple. Is there a way to do so in vs2013? When I install the package in vs2013 I get the following errors:

Set-DefaultScaffolder : Cannot get an instance of EnvDTE.DTE
At C:devWebApplication2packagesT4Scaffolding.Core.1.0.0	oolsinit.ps1:50 char:9
+         Set-DefaultScaffolder -Name CustomTemplate -Scaffolder T4Scaffolding.Cus ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Set-DefaultScaffolder], InvalidOperationException
    + FullyQualifiedErrorId : T4Scaffolding.Cmdlets.SetDefaultScaffolderCmdlet

Set-DefaultScaffolder : Cannot get an instance of EnvDTE.DTE
At C:devWebApplication2packagesT4Scaffolding.Core.1.0.0	oolsinit.ps1:51 char:9
+         Set-DefaultScaffolder -Name CustomScaffolder -Scaffolder T4Scaffolding.C ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Set-DefaultScaffolder], InvalidOperationException
    + FullyQualifiedErrorId : T4Scaffolding.Cmdlets.SetDefaultScaffolderCmdlet

Set-DefaultScaffolder : Cannot get an instance of EnvDTE.DTE
At C:devWebApplication2packagesT4Scaffolding.1.0.8	oolsinit.ps1:6 char:1
+ Set-DefaultScaffolder -Name DbContext -Scaffolder T4Scaffolding.EFDbContext -Sol ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Set-DefaultScaffolder], InvalidOperationException
    + FullyQualifiedErrorId : T4Scaffolding.Cmdlets.SetDefaultScaffolderCmdlet

Set-DefaultScaffolder : Cannot get an instance of EnvDTE.DTE
At C:devWebApplication2packagesT4Scaffolding.1.0.8	oolsinit.ps1:7 char:1
+ Set-DefaultScaffolder -Name Repository -Scaffolder T4Scaffolding.EFRepository -S ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Set-DefaultScaffolder], InvalidOperationException
    + FullyQualifiedErrorId : T4Scaffolding.Cmdlets.SetDefaultScaffolderCmdlet

Set-DefaultScaffolder : Cannot get an instance of EnvDTE.DTE
At C:devWebApplication2packagesMvcScaffolding.1.0.9	oolsinit.ps1:47 char:1
+ Set-DefaultScaffolder -Name Controller -Scaffolder MvcScaffolding.Controller -So ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Set-DefaultScaffolder], InvalidOperationException
    + FullyQualifiedErrorId : T4Scaffolding.Cmdlets.SetDefaultScaffolderCmdlet

Set-DefaultScaffolder : Cannot get an instance of EnvDTE.DTE
At C:devWebApplication2packagesMvcScaffolding.1.0.9	oolsinit.ps1:48 char:1
+ Set-DefaultScaffolder -Name Views -Scaffolder MvcScaffolding.Views -SolutionWide ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Set-DefaultScaffolder], InvalidOperationException
    + FullyQualifiedErrorId : T4Scaffolding.Cmdlets.SetDefaultScaffolderCmdlet

Set-DefaultScaffolder : Cannot get an instance of EnvDTE.DTE
At C:devWebApplication2packagesMvcScaffolding.1.0.9	oolsinit.ps1:49 char:1
+ Set-DefaultScaffolder -Name Action -Scaffolder MvcScaffolding.Action -SolutionWi ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Set-DefaultScaffolder], InvalidOperationException
    + FullyQualifiedErrorId : T4Scaffolding.Cmdlets.SetDefaultScaffolderCmdlet

Set-DefaultScaffolder : Cannot get an instance of EnvDTE.DTE
At C:devWebApplication2packagesMvcScaffolding.1.0.9	oolsinit.ps1:50 char:1
+ Set-DefaultScaffolder -Name UnitTest -Scaffolder MvcScaffolding.ActionUnitTest - ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Set-DefaultScaffolder], InvalidOperationException
    + FullyQualifiedErrorId : T4Scaffolding.Cmdlets.SetDefaultScaffolderCmdlet

Set-DefaultScaffolder : Cannot get an instance of EnvDTE.DTE
At C:devWebApplication2packagesMvcScaffolding.1.0.9	oolsinit.ps1:54 char:1
+ Set-DefaultScaffolder -Name View -Scaffolder $viewScaffolder -SolutionWide -DoNo ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Set-DefaultScaffolder], InvalidOperationException
    + FullyQualifiedErrorId : T4Scaffolding.Cmdlets.SetDefaultScaffolderCmdlet

推荐答案

我们正在为 Scaffolding 迁移到一个新系统,但现在,以管理员身份运行 VS 并使用我们更新的这个 -pre 版本:

We are moving to a new system for Scaffolding, but for now, run VS as admin and use this -pre version we've updated:

Install-Package MvcScaffolding -Version 1.0.8-vs2013 -Pre

Install-Package MvcScaffolding -Version 1.0.8-vs2013 -Pre

我会写博客.

这篇关于具有 Mvc5、EF6、VisualStudio 2013 中存储库的脚手架控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆