Application can't scaffold items

后端 未结 29 1047
自闭症患者
自闭症患者 2020-11-30 01:57

I created an MVC 5 application in VS 2013 Professional and then used EF 6.1 code first with an existing DB on SQL Server Express. When I try to create the views I’m using th

相关标签:
29条回答
  • 2020-11-30 02:16

    I had this problem too, I solved the problem by calling the base.onModelCreating in my DB context

    base.OnModelCreating(modelBuilder);
    
    0 讨论(0)
  • 2020-11-30 02:16

    I had the same problem where it wouldn't add scaffold items it seems that uninstalling entity-framework through the nuget package manager console works

    To Run Package Manager Console :

    Tools -> NuGet Package Manager -> Package Manager Console

    To Remove:

    UnInstall-Package EntityFramework

    To Reinstall:

    Install-Package EntityFramework

    Or in one command:

    Update-Package -reinstall EntityFramework

    I hope this can help someone as it took me a while to come to this.

    0 讨论(0)
  • 2020-11-30 02:18

    In my case NuGet added the following provider to the web.config:

    <provider invariantName="System.Data.SqlServerCe.4.0" type="System.Data.Entity.SqlServerCompact.SqlCeProviderServices, EntityFramework.SqlServerCompact"/>
    

    When I changed the provider to

    <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer"/>
    

    It solved the problem (costed me about 5 hours though to figure it out :-( )

    0 讨论(0)
  • 2020-11-30 02:18

    It is (I'm 99% positive) a connection string issue. Once i fixed the issue in Web.Config the error went away. I was using DB first, in another project and once I copied the DB first connection string from the App.config into the web.config (using the same name) it worked as expected.

    0 讨论(0)
  • 2020-11-30 02:18

    I realize this question is old now, but I thought I'd post what solved my issue in case it helps anyone later on. In my case, it was a combination of several things mentioned in other answers. To secure my connection string I had...

    1. Moved the connection string out of the Web.config file
    2. Moved the server name and password to a separate file referenced in the AppSettings portion of Web.config
    3. Used a SqlConnectionStringBuilder to put the elements together and then pass it to my context class constructor

    After doing this, I was unable to create any more controllers. To fix the issue, I had to ...

    1. Put the complete connection string back in Web.config AND remove the reference to the external connection string file
    2. Add a parameterless constructor to my context class and give it the name of my connectionString like this: public contextClass() : base("name=connectionStringName") { }

    3. Rebuild the solution, and create the controller again, and it worked!

    0 讨论(0)
  • 2020-11-30 02:18

    In my case, the problem was caused by an external app settings file:

    <appSettings configSource="appSettings.config" />
    

    Bringing the app settings back into the web.config file resolved the issue.

    <appSettings>
        <add key="webpages:Version" value="3.0.0.0" />
        <add key="webpages:Enabled" value="false" />
        <add key="ClientValidationEnabled" value="true" />
        <add key="UnobtrusiveJavaScriptEnabled" value="true" />
    </appSettings>
    
    0 讨论(0)
提交回复
热议问题