1対多リレーションシップで新しいレコードを作成するときに、Entity Frameworkに苦労しています。Winformsでのエンティティのバインド - 1対多
Person
PersonInternetAddresses
InternetAddresses
Entity Frameworkのは、人にナビゲーションプロパティをPersonInternetAddressesとInternetAddressesという名前のナビゲーションプロパティでEntityObjects人を作成している:私は、定義された以下の表をしました。
新しいInternetAddressesレコードを作成するには、いくつかのテキストフィールドとInternetAddressesへのバインディングソースからなるフォームを作成しました。
The EntityCollection has already been initialized. The InitializeRelatedCollection method should only be called to initialize a new EntityCollection during deserialization of an object graph.
私は推測している:私は次のエラーを取得しています最後の行に
internetAddressesBindingSource.AddNew();
(internetAddressesBindingSource.Current as InternetAddresses).Id = Guid.NewGuid();
(internetAddressesBindingSource.Current as InternetAddresses).Persons = InternetAddresses.Persons;
:私の「新しい」ボタンの下に
私は、次のコードを挿入しましたEntity Framework自体がPersonInternetAddressesレコードを作成することを意味するInternetAddressesのナビゲーションプロパティで人物を設定することはできません。モデルにPersonsInternetAddresses EntityObjectがないので、私はかなり固執しています!