使用者程式碼未處理 System.Data.UpdateException HResult=-2146233087 Message=更新實體時發生錯誤。詳細資訊請參閱內部例外狀況。 Source=System.Data.Entity StackTrace: 於 System.Data.Mapping.Update.Internal.UpdateTranslator.Update(IEntityStateManager stateManager, IEntityAdapter adapter) (略..........) InnerException: System.Data.EntityCommandCompilationException HResult=-2146232005 Message=準備此命令定義時發生錯誤。請參閱內部例外狀況以取得詳細資訊。 Source=System.Data.Entity StackTrace: 於 System.Data.Mapping.Update.Internal.UpdateTranslator.CreateCommand(DbModificationCommandTree commandTree) (略..........) InnerException: System.InvalidOperationException HResult=-2146233079 Message=由於該物件目前的狀態,導致作業無效。 Source=Oracle.DataAccess StackTrace: 於 Oracle.DataAccess.Client.SqlGen.DmlSqlGenerator.ExpressionTranslator.Visit(DbScanExpression expression) (略..........) 於 System.Data.Mapping.Update.Internal.UpdateTranslator.CreateCommand(DbModificationCommandTree commandTree)
查了快一個小時,被「該物件目前的狀態」誤導偵錯方向,一直看不出自己的LINQ語法或物件有什麼奇怪的地方,最後去查了DB才發現是資料表被異動過,Primary Key未設定導致新增失敗,將 Primary Key 設上去之後,就不再發生此問題了。
沒有留言:
張貼留言