zoukankan      html  css  js  c++  java
  • Store update, insert, or delete statement affected an unexpected number of rows ({0}).

    问题描述

    Store update, insert, or delete statement affected an unexpected number of rows ({0}). Entities may have been modified or deleted since entities were loaded. Refresh ObjectStateManager entries.

    存储区更新、插入或删除语句影响到了意外的行数({0})。实体在加载后可能被修改或删除。刷新 ObjectStateManager 项。

    原因分析

    使用 Entity Framework 更新记录时出现上述异,原因是 Model 或 Entity 实体对象的 Key 值没有赋值,无法在数据库对应表中找到对应的记录,也就无法执行更新操作。

    一:View中无此列绑定, MODEL中列加了[ScaffoldColumn(false)] 是否自动加入隐藏绑定文本

    二:MODEL中设置了绑定除外

    解决办法

    在 View 视图中添加一个隐藏的 Key 值,如:@Html.HiddenFor(model => model.id)

    还有不要在model中有[Bind(Exclude=" key 列")]这样的话就算你加了这个隐藏列也不行,这个就是绑定时排除啊,你还怎么绑定。。。

  • 相关阅读:
    spring事物配置,声明式事务管理和基于@Transactional注解的使用
    spring集成ehcache本地缓存
    Java并发编程:volatile关键字解析
    Callable接口、Runable接口、Future接口
    Sorting It All Out
    Borg Maze
    Agri-Net
    Highways
    Truck History
    Arbitrage
  • 原文地址:https://www.cnblogs.com/guo0/p/3224384.html
Copyright © 2011-2022 走看看