我创建了这个 MVC4 Web 应用程序并使用了本地 MDF(localdb?)。它位于\App_Data
我的项目的文件夹中。它的名字是SiteDatabase.mdf
。
但是现在我正在为连接字符串而苦苦挣扎,我该如何“链接”它呢?
我懂了:
<add name="DefaultConnection" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=SiteDatabase;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\SiteDatabase.mdf" providerName="System.Data.SqlClient" />
SiteDatabase.mdf 位于我的App_Data
文件夹中。
我得到的错误:
Server Error in '/' Application.
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: 50 - Local Database Runtime error occurred. Cannot create an automatic instance. See the Windows Application event log for error details.)