Application can't scaffold items

后端 未结 29 1203
自闭症患者
自闭症患者 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: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!

提交回复
热议问题