1

EntityFrameworkファイルを作成しました。私のデータベースはMyDBと呼ばれています。私のEntityFrameworkファイルはMyDB.edmxであり、既存の接続文字列(MyDBConnectionString)を使用してedmxモデルを生成しました。

さらに2つの接続文字列を作成しました:
MyDBEntities
MyDBContainer

これらは何のためにありますか?それらはまったく同じように見え、両方とも私の古い接続文字列からの情報を持っています。

古い接続文字列はまだ必要ですか?

詳細情報で更新:

接続文字列は次のとおりです。

<add name="MyDBConnectionString" connectionString="Data Source=localhost;Initial Catalog=MyDB;Persist Security Info=False;User ID=MyDB;Password=MyDB" providerName="System.Data.SqlClient" />
<add name="MyDBEntities" connectionString="metadata=res://*/App_Code.MyDB.csdl|res://*/App_Code.MyDB.ssdl|res://*/App_Code.MyDB.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=localhost;Initial Catalog=MyDB;Persist Security Info=True;User ID=MyDB;Password=MyDB;MultipleActiveResultSets=True&quot;" providerName="System.Data.EntityClient" />
<add name="MyDBContainer" connectionString="metadata=res://*/App_Code.MyDB.csdl|res://*/App_Code.MyDB.ssdl|res://*/App_Code.MyDB.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=localhost;Initial Catalog=MyDB;Persist Security Info=True;User ID=MyDB;Password=MyDB;MultipleActiveResultSets=True&quot;" providerName="System.Data.EntityClient" />

MyDBConnectionStringという最初のものを作成しました。次に、データベースVisual Studioからedmxモデルを生成したときに、MyDBEntitiesおよびMyDBContainer接続文字列を作成しました。他の2つ(エンティティとコンテナ)は何のためにありますか?元の接続文字列はもう必要ありませんか?

4

1 に答える 1

2

3つのconnectionStringがあります。2つはEFconnectionStringsで、1つ(MyDBConnectionString)はADO.NET用です。

必要なのはEFconnectionStringsの1つだけです。モデルが参照しているものを保持します。モデル自体と同じ名前になります。

おそらくMyDBConnectionStringも保持する必要があります。たとえば、フォーム認証を使用する場合、SQLメンバーシッププロバイダーを構成する場合は、そのconnectionStringが必要になります。同じDBを指すように、両方の同期を維持する必要があります。

于 2010-04-23T12:11:14.760 に答える