尝试建立到我的PC上运行的SQL Server 2012(localdb)的MVC连接时出错

时间:2013-10-03 16:40:31

标签: sql-server asp.net-mvc

我已经设置了我的web.config:

<add name="DefaultConnection" connectionString="Data Source='C:\Users\Marilou\AppData\Local\Microsoft\Microsoft SQL Server Local DB\Instances\v11.0\authentication.mdf';Initial Catalog=javacert;Persist Security Info=True;User ID=sa;Password=yyy" providerName="System.Data.SqlClient" />

但我收到的消息是:

   Message=The provider did not return a ProviderManifestToken string.
   Source=EntityFramework
   StackTrace:
        at System.Data.Entity.Core.Common.DbProviderServices.GetProviderManifestToken(DbConnection connection)
        at System.Data.Entity.Utilities.DbProviderServicesExtensions.GetProviderManifestTokenChecked(DbProviderServices providerServices, DbConnection connection)
   InnerException: System.Data.SqlClient.SqlException
        HResult=-2146232060
        Message=A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
        Source=.Net SqlClient Data Provider
        ErrorCode=-2146232060

1 个答案:

答案 0 :(得分:0)

好像你正在使用LocalDB。从这篇MSDN文章(http://blogs.msdn.com/b/sqlexpress/archive/2011/07/12/introducing-localdb-a-better-sql-express.aspx)中,连接字符串如下:

Data Source=(localdb)\v11.0;Integrated Security=true;AttachDbFileName=C:\MyData\Database1.mdf".