Scaffolding controller doesn't work with visual studio 2013 update 2

后端 未结 16 2980
别跟我提以往
别跟我提以往 2020-11-27 03:54

PROBLEM:

I have updated to Visual Studio 2013 update 2 and now I cannot scaffold controllers.

The problem is not project specific: when I try to scaffold

相关标签:
16条回答
  • 2020-11-27 04:16

    I have performed following to solve this issue:

    1. In Package Manager check if you have MVCScffolding or T4Scaffolding (Core or pre release for vs2013)
    2. Uninstall all packaged that depend on any of MVCScaffolding or T4Scaffolding
    3. Copy CodeTemplates Folder in full (Do not replace your custom templates but make sure you have rest of the files from root of this folder. I take that you have done that part as you have customised some templates so you know where this folder is)
    4. Build Your project and close it.
    5. Restart Visual Studio under admin mode
    6. Open Package Manager Console (it should not have any errors and you can see PM> without errors.
    7. Right Click on Controller folder and choose Add->New Scaffolding Item or Choose Add->Controller both should ask which one you want and then choose MVC5 scaffold or which ever appears in list.
    8. You will then get to select your parameters if its controller you might need to choose DBContext or repository etc.

    This produced the controller and relevant views for me.

    I added a custom partial view called QuickView in that folder however this scaffolding procedure did not consider that and only generated views that it was doing by default. I am not sure if you need to add these custom views in a file to tell Scaffolder to generate those as well.

    0 讨论(0)
  • 2020-11-27 04:18

    For me what worked was to make sure the <configSections> node in the web.config file was the first node immediately after <configuration> node.

    Initially, when I added my connectionStrings, I had actually placed it before the configSections, which made the Scaffold tool break.

    Seems like when the scaffolding runs and tries to grab connection info, it expects the config section for the entityFramework node to be there already so it know what DB provider to use, but when I had the connection string before configSections, it didn't know to use LocalDB (which is what my conn string was using).

    0 讨论(0)
  • 2020-11-27 04:19

    Hey for all of you that nothing works, the real answer is you need to remove ANYTHING that has a configSource on the web.config and the connection string needs to be inlined.

    EDIT:

    Someone pointed out that it needs to be only <configSettings>, <appSettings>, and <connectionStrings> tags NOT using a configSource attribute. And that he was still able to use configSource attributes elsewhere, such as the rewriter tag.

    I think it's that the tooling cannot follow configSource locations for the stuff it uses like connection strings and application settings.

    Microsoft should be on this issue if not fixed yet.

    EDIT 2:

    Even thought @awrigley has marked his answer as correct it's a known Visual Studio bug. I've managed to tell then and I think it will get some attention soon. https://github.com/aspnet/Tooling/issues/169#issuecomment-144197015

    0 讨论(0)
  • 2020-11-27 04:19

    I think, the problem is due to bad configuration in web.config file.

    In my case I had multiple <entityFramework> sections in web.config, and the problem resolved after I changed the configurations.

    0 讨论(0)
提交回复
热议问题