问题描述

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 列")]这样的话就算你加了这个隐藏列也不行,这个就是绑定时排除啊,你还怎么绑定。。。

Store update, insert, or delete statement affected an unexpected number of rows ({0}).的更多相关文章

  1. system.Data.Entity.Infrastructure.DbUpdateConcurrencyException: Store update, insert, or delete statement affected an unexpected number of rows (0) 问题

    页面控件没有做限制.提交后还可以继续点击,造成了在短时间内的多次请求.查看日志两次错误在200ms之内. 错误信息 system.Data.Entity.Infrastructure.DbUpdate ...

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

    EF6进行Insert操作的时候提示错误 Store update, insert, or delete statement affected an unexpected number of rows ...

  3. The use of function Merge (update、insert、delete)

    1.The use of function merge(update.insert.delete) Example: #1.Initialize the data create table #test ...

  4. SQL server触发器中 update insert delete 分别给写个例子被。

    SQL server触发器中 update insert delete 分别给写个例子以及解释下例子的作用和意思被, 万分感谢!!!! 主要想知道下各个语句的书写规范. INSERT: 表1 (ID, ...

  5. 执行update, insert,delete 语句, 不返回结果集,(类型化参数)

    /// <summary> /// 执行update, insert,delete 语句, 不返回结果集,(类型化参数) /// </summary> /// <para ...

  6. Oracle 增删改(INSERT、DELETE、UPDATE)语句

    Ø  简介 本文介绍 Oracle 中的增删改语句,即 INSERT.DELETE.UPDATE 语句的使用.是时候展现真正的技术了,快上车: 1.   插入数据(INSERT) 2.   修改数据( ...

  7. using the library to generate a dynamic SELECT or DELETE statement mysqlbaits xml配置文件 与 sql构造器 对比

    https://github.com/mybatis/mybatis-dynamic-sql MyBatis Dynamic SQL     What Is This? This library is ...

  8. SQL SERVER 2005删除维护作业报错:The DELETE statement conflicted with the REFERENCE constraint "FK_subplan_job_id"

    案例环境: 数据库版本: Microsoft SQL Server 2005 (Microsoft SQL Server 2005 - 9.00.5000.00 (X64) ) 案例介绍: 对一个数据 ...

  9. 懒人小工具:自动生成Model,Insert,Select,Delete以及导出Excel的方法

    在开发的过程中,我们为了节约时间,往往会将大量重复机械的代码封装,考虑代码的复用性,这样我们可以节约很多时间来做别的事情.最近跳槽到一节webform开发的公司,主要是开发自己公司用的ERP.开始因为 ...

随机推荐

  1. [BZOJ 1029] [JSOI2007] 建筑抢修 【贪心】

    题目链接:BZOJ - 1029 题目分析 使用一种贪心策略. 现将任务按照deadline从小到大排序. 然后枚举每一个任务,如果当前消耗的时间加上完成这个任务的时间不会超过这个任务的deadlin ...

  2. 自己写的carousel

    可以 function appendRight() { //alert("right"); lastItem = itemsRight[urls.length - ]; first ...

  3. Android假退出不是流氓行为

    转自Android假退出不是流氓行为 关于Android程序的退出,目前我们没有再用System.exit(0)或killProcess的机制而是直接用Activity.finish假退出了.因此在内 ...

  4. SQL Server 2008 数据库误删除数据的恢复

    原文:SQL Server 2008 数据库误删除数据的恢复 原文:http://www.cnblogs.com/dudu/archive/2011/10/15/sql_server_recover_ ...

  5. [LeetCode#128]Word Ladder II

    Problem: Given two words (start and end), and a dictionary, find all shortest transformation sequenc ...

  6. dedecms网站如何做在线订单功能

    做网站的时候经常会遇到做在线订单的这个功能,而且这个功能会在企业网站的建设中经常的遇到,今天51模板集就拿物流网的在线订单功能做一个详细的介绍. 第一步:自定义表单 打开后台:核心-->自定义表 ...

  7. Delphi 用Web App Debugger简单调试ISAPI 转

    用Web App Debugger简单调试ISAPI   以isapi为例: 1.新建一个project,用isapi/nsapi: 2.remove这个project中所有的unit: 3.加进你用 ...

  8. 在Ubuntu中设置中文输入法

    在Ubuntu中设置中文输入法 */--> pre { background-color: #2f4f4f;line-height: 1.6; FONT: 10.5pt Consola,&quo ...

  9. 还原dede数据后系统基本参数空白栏目无显示的解决方法

    有时dedecms开发的网站在更换空间还原数据后,出现"系统基本参数"空白,而且可以看到tag也没有了. 大家不妨看看后台"数据库备份/还原"处,已经还原后的表 ...

  10. bzoj1827 [Usaco2010 Mar]gather 奶牛大集会

    不就是移一下树根,回溯一下吗? 诶?黄学长为什么可以直接找? 诶?这不是重心吗? YY了一下证明 很简单 由于重心max{sz[v]} <= sz[u] / 2的性质,可以证明每一步远离重心的移 ...