Visual Studio 2012 MVC Local DB Add Table menu option missing

前端 未结 3 1179
没有蜡笔的小新
没有蜡笔的小新 2020-12-21 16:34

Usually connect to an external database but I wanted to fiddle with creating a project with a local database. I am using SQLServer Express Local Database, not CE.

I

3条回答
  •  没有蜡笔的小新
    2020-12-21 16:55

    I had a similar problem only with Visual Studio 2012 Express for Web following along with the "Getting started with ASP.Net MVC3" at www.asp.net. The tutorial used a Sql Server Compact edition but I have SQL Express 2012 so I changed the connection string to have the data source point at my local instance, .\SQLExpress2012. The app worked fine and was able to read and write to the database. However I could not edit the database in the Visual Studio Express Database Explorer (all the context menu options were missing except "refresh" and "properties).

    I found that changing the data source in the connection string to "Data Source=(LocalDB)\v11.0;" fixed the problem. I read somewhere that if you use LocalDb instead of the SQL Server instance name then it will be accessed under your user account - must have been some kind of permissions issue.

    The whole (working) connnection string is: "Data Source=(LocalDB)\v11.0;AttachDBFilename=|DataDirectory|Movies.mdf;Integrated Security=True;"

    Hope this saves someone a bunch of hours pulling their hair out, I'm almost bald now :)

提交回复
热议问题