6

共有サーバーでASP.NETMVCを実行していますが、System.Data.EntityClientを介したSQLへの接続に問題があります。以下は、私のホースプロバイダーがSQLに接続するために私に与えた接続文字列と、VSが開発中にローカルマシン用に構成した接続文字列です。サーバーにデプロイしたときの接続文字列はどのようになりますか?

私のホスティングプロバイダーから:

<add name="WeddingsDBEntities" 
  connectionString="data Source=<server name>; Initial Catalog=<db name>; User ID=<user ID>; Password=<password>;" 
  providerName="System.Data.EntityClient"/>

VSから(開発中):

connectionString="metadata=res://*/Models.WeddingsModel.csdl|res://*/Models.WeddingsModel.ssdl|res://*/Models.WeddingsModel.msl;provider=System.Data.SqlClient;provider connection string="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\WeddingsDB.mdf;Integrated Security=True;User Instance=True;MultipleActiveResultSets=True"" providerName="System.Data.EntityClient"

ありがとう!

4

3 に答える 3

9

次の形式のエンティティ接続文字列内に接続文字列をラップする必要があります。

<add name="Name"
  connectionString="metadata=<Conceptual Model>|<Store Model>|<Mapping Model>;
  provider=<Underlying Connection Provider>;
  provider connection string=&quot;<Underlying ConnectionString>&quot;" 
  providerName="System.Data.EntityClient"/>

それ以外の:

<add name="WeddingsDBEntities" 
  connectionString="data Source=<server name>; Initial Catalog=<db name>; User ID=<user ID>; Password=<password>;" 
  providerName="System.Data.EntityClient"/>

これを使って:

<add name="WeddingsDBEntities"
  connectionString="metadata=res://*/Models.WeddingsModel.csdl|res://*/Models.WeddingsModel.ssdl|res://*/Models.WeddingsModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;data Source=<server name>; Initial Catalog=<db name>; User ID=<user ID>; Password=<password>;MultipleActiveResultSets=True&quot;" 
  providerName="System.Data.EntityClient"/>
于 2009-03-28T20:57:11.747 に答える
1

プロバイダーを entityclient から sqlclient に変更します (コードが最初に EF であると仮定します)。

providerName="System.Data.EntityClient" />

providerName="System.Data.SqlClient" />

于 2016-03-25T04:36:51.307 に答える