ObjectContext は、メモリ内オブジェクトのコンテナーを表します。 オブジェクト コンテキストは、他のクラスやインターフェイスと連携して、オブジェクトの ID、状態、オブジェクトのプロパティの元の値と現在の値を管理し、キャッシュ内の各オブジェクトに対して行われた変更を追跡します。 オブジェクト コンテキストにオブジェクトをアタッチする方法については、「オブジェクトのアタッチとデタッチ (Entity Framework)」を参照してください。 ここでは、変更追跡、ID 解決、および状態管理がオブジェクト コンテキストでどのように行われるかについて説明します。 変更の追跡 オブジェクト グラフの変更追跡情報は、アタッチされている各オブジェクトについて ObjectContext が作成する ObjectStateEntry オブジェクトに格納されます。 ObjectStateEnt
本記事は、Microsoftの本社副社長であり、ASP.NETやSilverlightなどの開発チームを率いるScott Guthrie氏のブログを翻訳したものです。氏の許可を得て転載しています。 .NET Framework 4では、System.Data.Entity名前空間にあるデータ・アクセス・ライブラリであるEntity Framework(EF)の大幅に改善されたバージョンが一緒に出荷されます。 Entity Frameworkが.NET Framework 3.5 SP1で最初に導入されたとき、開発者はその最初のリリースで不完全であると思われる点ついて、多くのフィードバックをくれました。SQLチームはこのフィードバックを聞き入れ、.NET 4と一緒に出荷されるEFでそれに対処できるように本当に努力しました。 EF 4の大きな改善点には以下のものがあります。 POCOサポート:
EntityFramework5で確認 DBの最大文字列長に合わせて、エンティティにもMaxLengthプロパティが表示されるけど MaxLengthより長い文字列をエンティティに突っ込んでSaveChanges()したら何が起こるの?と思ってやってみた。 (普通はデータアノテーションとかで事前に検証するから、なかなかそんな状況にならないと思うけど) エンティティのプロパティに文字列をセットした時点では何も起こらず。 SaveChanges()時に例外発生。DbEntityValidationExceptionとな。 SQLExceptionになると思ってたけど、EntityFramework側でちゃんと検証してるんだ…。 検証の内容を出力するには下記のようなコードになった。深い。深いぞう。 try { db.SaveChanges(); } catch (System.Data.Enti
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く