System.Data.Entity.Infrastructure.DbUpdateException

异常描述:
 
捕捉到 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。
 
异常原因及处理: 数据库中该实体表无主键,设置主键后更新模型就解决
posted @ 2018-09-21 11:29  ZaraNet  阅读(1632)  评论(0编辑  收藏  举报