我使用SelfTracking實體,一切工作正常,直到我們在參考詳細信息表中添加了一些字段。我不明白引用外鍵有什麼問題!我沒有設計數據庫模式,但我可以看到一切看起來不錯!實體框架4 InvalidOperationException雖然插入或更新
這是堆棧跟蹤的異常消息。
A circular relationship path has been detected while enforcing a referential integrity constraints. Referential integrity cannot be enforced on circular relationships.
System.Data.Entity
Void FixupForeignKeysByReference(System.Collections.Generic.List`1[System.Data.Objects.EntityEntry])
at System.Data.Objects.EntityEntry.FixupForeignKeysByReference(List`1 visited)
at System.Data.Objects.EntityEntry.FixupForeignKeysByReference(List`1 visited)
at System.Data.Objects.EntityEntry.FixupForeignKeysByReference(List`1 visited)
at System.Data.Objects.EntityEntry.FixupForeignKeysByReference()
at System.Data.Objects.ObjectStateManager.FixupKey(EntityEntry entry)
at System.Data.Objects.EntityEntry.AcceptChanges()
at System.Data.Objects.EntityEntry.ChangeObjectState(EntityState requestedState)
at System.Data.Objects.ObjectStateManager.ChangeObjectState(Object entity, EntityState entityState)
at Aitisi.Data.Model.SelfTrackingEntitiesContextExtensions.ChangeEntityStateBasedOnObjectState(ObjectContext context, IObjectWithChangeTracker entity) in D:\Workfile\Web Projects\Allatini_Egrisis_Aitiseis\Aitisi.Data.Model\AitisiSelfTrackModel.Context.Extensions.cs:line 732
at Aitisi.Data.Model.SelfTrackingEntitiesContextExtensions.HandleEntity(ObjectContext context, EntityIndex entityIndex, RelationshipSet allRelationships, IObjectWithChangeTracker entity) in D:\Workfile\Web Projects\Allatini_Egrisis_Aitiseis\Aitisi.Data.Model\AitisiSelfTrackModel.Context.Extensions.cs:line 597
at Aitisi.Data.Model.SelfTrackingEntitiesContextExtensions.ApplyChanges[TEntity](ObjectContext context, String entitySetName, TEntity entity) in D:\Workfile\Web Projects\Allatini_Egrisis_Aitiseis\Aitisi.Data.Model\AitisiSelfTrackModel.Context.Extensions.cs:line 85
at Aitisi.Data.Model.SelfTrackingEntitiesContextExtensions.ApplyChanges[TEntity](ObjectSet`1 objectSet, TEntity entity) in D:\Workfile\Web Projects\Allatini_Egrisis_Aitiseis\Aitisi.Data.Model\AitisiSelfTrackModel.Context.Extensions.cs:line 41
at Aitisi.Repository.Data.MtrLinesRepository.Update(MTRLINES mtrLine) in D:\Workfile\Web Projects\Allatini_Egrisis_Aitiseis\Aitisi.Repository.Data\MtrLinesRepository.cs:line 37
這是我第一次遇到這種錯誤。 任何幫助表示讚賞。
謝謝。
這是很難說發生了什麼,如果你不顯示在你的模型有什麼改變,你在做什麼修改。順便說一句。這裏是相同的問題:http://social.msdn.microsoft.com/Forums/en/adodotnetentityframework/thread/86aae7f5-88f5-4473-8f69-8030973bf544 – 2011-05-09 21:21:23