2013-06-04 54 views
5

我使用MVC3在Visual Studio 2012中創建了一個簡單的Web應用程序,並將它發佈到Azure上。我的網絡應用程序在發佈時找不到我的數據庫

當我在本地運行它時,一切正常。但是當我發佈時,有一個表格使用我創建的分區不會加載。 錯誤消息是巨大的,但像這樣開頭:

Exception Details: System.ComponentModel.Win32Exception: The system cannot find the file specified 

Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. 

Stack Trace: 


[Win32Exception (0x80004005): The system cannot find the file specified] 

[SqlException (0x80131904): 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: 52 - Unable to locate a Local Database Runtime installation. Verify that SQL Server Express is properly installed and that the Local Database Runtime feature is enabled.)] 
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) +5296071 
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) +558 

而繼續下去。

有三個表,其中一個是由Visual Studio在其Web App示例上創建的Default。 我自己創建的另外兩個,發佈時都不工作(在本地運行時完全正常)。

我假設的問題是在連接字符串,如果有什麼更多的,我應該在這裏提出,請諮詢:

<connectionStrings> 
<add name="DefaultConnection" providerName="System.Data.SqlClient" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=aspnet-Porta-comprimidos-20130503163319;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnet-Porta-comprimidos-20130503163319.mdf" /> 
<add name="RemedioDBContext" 
    connectionString="Data Source=|DataDirectory|\MeuPortaComprimidosDB.sdf" 
    providerName="System.Data.SqlClient"/> 
<add name="RemedioTempDBContext" 
    connectionString="" 
    providerName="System.Data.SqlClient"/> 

任何人都可以,請幫助我嗎?我研究了很多,並不知道如何處理它(是的,我是新來的)。

回答

3

您的connection strings設置的數據源爲LocalDb,默認情況下,它不會在Windows Azure計算機上安裝,並且您無法使用它(除非安裝它)。

您必須將您的數據庫遷移到Windows Azure SQL並相應地更改您的connection string。在http://msdn.microsoft.com/en-us/library/windowsazure/ee730904.aspx

+0

但 「DefaultConnection」,這是用來賬戶(成員,角色等)

更多信息,做工精細。如果那是問題,這個db是不是也被打破了? – soneca

+0

是的,它不應該工作。你確定這是'membership'提供者使用的連接字符串嗎? – haim770

+0

是的,connectionStringName =「DefaultConnection」 – soneca

相關問題