テクノロジ: ASP.NET MVC3、Entity Framework 4、多層アプリ
0 対 1 の関係にある 2 つのテーブルがあります。duplicata には 0 個または 1 個の pagamento を含めることができ、pagamento には 1 個の duplicata のみを含めることができます。リンク
新しい Pagameto エンティティを作成し、1 つの Dupliacata に追加すると、Duplicata の行がデータベースに保存され、次のエラーが発生します。
A referential integrity constraint violation occurred: The property values that define the referential constraints are not consistent between principal and dependent objects in the relationship.
次の画像は、1 つのパガメントを持つエンティティ Duplicata を示しています。 リンク
そして、コードはエラーを取得します:
context.Duplicata.Attach(duplicata);
context.ObjectStateManager.ChangeObjectState(duplicata, EntityState.Modified);
context.SaveChanges();