異常描述:
捕捉到 System.Data.Entity.Infrastructure.DbUpdateException
HResult=-2146233087
Message=無法更新 EntitySet“CashRequest”,因為它有一個 DefiningQuery,而 <ModificationFunctionMapping> 元素中沒有支持當前操作的 <InsertFunction> 元素。
Source=EntityFramework
StackTrace:
在 System.Data.Entity.Internal.InternalContext.SaveChanges()
在 System.Data.Entity.Internal.LazyInternalContext.SaveChanges()
在 System.Data.Entity.DbContext.SaveChanges()
在 Core.ServiceBase`1.Add(T entity) 位置 d:\WORK\LssNew\Core\ServiceBase.cs:行號 171
在 Lss.App.Controllers.MechanicController.CashAction(Int32 WorkerID, Double CashNum) 位置 d:\WORK\LssNew\Lss.App\Controllers\MechanicController.cs:行號 1201
InnerException: System.Data.Entity.Core.UpdateException
HResult=-2146232032
Message=無法更新 EntitySet“CashRequest”,因為它有一個 DefiningQuery,而 <ModificationFunctionMapping> 元素中沒有支持當前操作的 <InsertFunction> 元素。
Source=EntityFramework.SqlServer。
HResult=-2146233087
Message=無法更新 EntitySet“CashRequest”,因為它有一個 DefiningQuery,而 <ModificationFunctionMapping> 元素中沒有支持當前操作的 <InsertFunction> 元素。
Source=EntityFramework
StackTrace:
在 System.Data.Entity.Internal.InternalContext.SaveChanges()
在 System.Data.Entity.Internal.LazyInternalContext.SaveChanges()
在 System.Data.Entity.DbContext.SaveChanges()
在 Core.ServiceBase`1.Add(T entity) 位置 d:\WORK\LssNew\Core\ServiceBase.cs:行號 171
在 Lss.App.Controllers.MechanicController.CashAction(Int32 WorkerID, Double CashNum) 位置 d:\WORK\LssNew\Lss.App\Controllers\MechanicController.cs:行號 1201
InnerException: System.Data.Entity.Core.UpdateException
HResult=-2146232032
Message=無法更新 EntitySet“CashRequest”,因為它有一個 DefiningQuery,而 <ModificationFunctionMapping> 元素中沒有支持當前操作的 <InsertFunction> 元素。
Source=EntityFramework.SqlServer。
異常原因及處理: 數據庫中該實體表無主鍵,設置主鍵后更新模型就解決