2012-06-29 57 views
0

請幫我這個! 我已經把我的網站上somee.com,他們給這個連接字符串託管網站後連接字符串問題

Connection string: workstation id=GWAPDataBase.mssql.somee.com;packet size=4096;user id=xxxx;pwd=xxxxx;data source=GWAPDataBase.mssql.somee.com;persist security info=False;initial catalog=GWAPDataBase 

和我的自動生成的連接字符串時,我是本地主機上是

<add name="ApplicationServices" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnetdb.mdf;User Instance=true" providerName="System.Data.SqlClient" /> 
<add name="GWAP_Entities" connectionString="metadata=res://*/App_Code.GWAPModel.csdl|res://*/App_Code.GWAPModel.ssdl|res://*/App_Code.GWAPModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=.\SQLEXPRESS;attachdbfilename=|DataDirectory|\aspnetdb.mdf;integrated security=True;user instance=True;multipleactiveresultsets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" /> 

我試圖修改它,但我得到一個錯誤,說

The specified named connection is either not found in the configuration, not intended to be used with the EntityClient provider, or not valid.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ArgumentException: The specified named connection is either not found in the configuration, not intended to be used with the EntityClient provider, or not valid.

Source Error:

Line 19: #region Constructors Line 20: Line 21: public GWAP_Entities() Line 22: : base(ConnectionString, ContainerName) Line 23: {

請幫我怎麼修改連接字符串?

+1

您可能不希望放棄數據庫框的域名,用戶名和密碼。只是說。 –

+0

僅供參考:請確保這些不是您的連接字符串的實際用戶名和密碼。 –

+0

更改密碼_right now_ – SLaks

回答

0

聽起來好像您的連接字符串名稱和實體框架所期望的名稱不匹配。如果沒有關於代碼外觀的更多信息,我假設您使用Visual Studio中的嚮導從數據庫生成模型。當你這樣做時,你輸入連接字符串的名字,然後在你的設計器文件中被硬編碼。例如:

public FooEntity() : base("name=FooEntity", "FooEntity") 
{ 
    this.ContextOptions.LazyLoadingEnabled = true; 
    OnContextCreated(); 
} 

在這種情況下字符串「FooEntity」需要是連接字符串的名稱。如果它們不同,則不會找到連接字符串。確保這些值匹配。

+0

他們匹配,我現在試圖把連接字符串是這樣的: <配置> 節點 <添加 名= 「ApplicationServices」 的connectionString =「數據源= GWAPDataBase.mssql.somee.com; 初始目錄= GWAPDataBase; 持續安全信息= FALSE; 用戶ID = XXXX; 密碼= XXXXX 「/> <添加 名稱= 」GWAP_Entities「 的connectionString =」 數據源= GWAPDataBase.mssql.somee.com; 初始目錄= GWAPDataBase; Persist Security Info = False; User ID = xxxxx; Password = xxx xx「 providerName =」System.Data.SqlClient「/> 但也沒有字 – Ruba

+0

您可以發佈設計器文件的構造函數方法的代碼嗎? –

+0

public const string ConnectionString =「name = GWAP_Entities」; public const string ContainerName =「GWAP_Entities」;公共GWAP_Entities() :base(ConnectionString,ContainerName) this.ContextOptions.LazyLoadingEnabled = true; } public GWAP_Entities(string connectionString) :base(connectionString,ContainerName) { this.ContextOptions。LazyLoadingEnabled = true; } 公共GWAP_Entities(EntityConnection連接) :基座(連接,容器名稱) { this.ContextOptions.LazyLoadingEnabled = TRUE; } – Ruba