最新文章 (全部类别)
OneDrive安装闪退解决方案
VS2022正在加载设计器,连接到已命名的管道时发生超时
客户端部署.NET7程序 | 客户端安装环境
DevExpress.XtraTreeList.TreeList 组件自动定位当前记录
塑木地板行业ERP - 用户操作手册 - 软件安装&部署
塑木地板行业ERP - 用户操作手册 - 用户管理
塑木地板行业ERP - 用户操作手册 - 角色管理
塑木地板行业ERP - 用户操作手册 - 成品出入库历史记录
塑木地板行业ERP - 用户操作手册 - 成品出库(客户发货单)
塑木地板行业ERP - 用户操作手册 - 客户送货单(成品出库)
塑木地板行业ERP - 用户操作手册 - 销售订单
塑木地板行业ERP - 用户操作手册 - 成品入库
塑木地板行业ERP - 用户操作手册 - 成品库存查询
塑木地板行业ERP - 用户操作手册 - 仓库管理
塑木地板行业ERP - 用户操作手册 - 生产单
塑木地板行业ERP - 用户操作手册 - 物料类别管理
塑木地板行业ERP - 用户操作手册 - 物料清单
塑木地板行业ERP - 用户操作手册 - 客户管理
CSFrameworkV5-客户案例 - 科伦药业-骨折联络服务管理系统
装机必备|WindowsX64|官方软件下载|.NET开发人员
Winform+DevExpress使用GridLookUpEdit实现订单明细选择商品,并自动添加新商品记录
VS2022 关停ServiceHub.IntellicodeModelService.exe服务占用CPU及内存过高
修改密码 - MiniFramework蝇量框架 - Winform框架
主窗体导航菜单NavbarControl 介绍 - MiniFramework蝇量框架 - Winform框架
.NETCore WebApi阻止接口重复调用(请求并发操作)
VS2022消除编译警告
“SymmetricAlgorithm.Create(string)”已过时:“Cryptographic factory methods accepting an algorithm name are obsolete. Use the parameterless Create factory method on the algorithm type instead
SHA256Managed/SHA512Managed已过时:Derived cryptographic types are obsolete. Use the Create method on the base type instead
MD5CryptoServiceProvider已过时:Derived cryptographic types are obsolete. Use the Create method on the base type instead
C#使用HttpClient获取IP地址位置和网络信息
判断IP是否是外网IP、内网IP
C#使用HttpClient获取公网IP
WebRequest.Create(string)已过时:WebRequest, HttpWebRequest, ServicePoint, and WebClient are obsolete. Use HttpClient instead
C#根据第三方提供的IP查询服务获取公网外网IP地址
html/dom/js/javascript开发记录
调试ASP.NETCore Web站点 - 清理IISExpress缓存数据(js,css)
EFCore+Oracle根据不同的Schema连接数据库
主程序集成CSFramework.EF 数据库框架(.NET7版本)
CSFramework.EF数据库框架简介(.NET8+EFCore)
迁移ECS服务器:导致ORACLE监听服务启动不了解决方案
SQLite数据库
VS2022编译报错:Visual Studio 容器工具需要 Docker Desktop
.NET 9 预览版+C#13新功能
EFCore禁用实体跟踪
WebApi开发框架V3.0 (.NETCore+EFCore) 增加AppSettings全局参数类
C#获取应用程序所有依赖的程序集
LINQ Expression 多条件复合条件组合(And/Or)
CSFrameworkV6客户案例 - MHR - 宁德时代制造人力资源系统
CS软件授权注册系统V3 - 发布证书
C/S软件授权注册系统V3.0(Winform+WebApi+.NET8+EFCore版本)
.net敏捷开发,创造卓越

The object cannot be deleted because it was not found in the ObjectStateManager


 

 错误信息

System.InvalidOperationException:“The object cannot be deleted because it was not found in the ObjectStateManager.”

对象状态管理器 ObjectStateManager 不存在该对象,不可删除!

 

图片

 

解决方案

 

C# 全选
  public virtual int Remove<T>(List<T> entities) where T : class
        {
            //对象状态管理器设置【删除】状态           
            foreach (var obj in entities)
            {
                _dbContext.Entry(obj).State = EntityState.Deleted;
            }

            //删除
            _dbContext.Set<T>().RemoveRange(entities);

            return SaveChanges(false);
        }

 

版权声明:本文为开发框架文库发布内容,转载请附上原文出处连接
C/S框架网
上一篇:An exception has been raised that is likely due to a transient failure. Consider enabling transient error resiliency by adding 'EnableRetryOnFailure()'
下一篇:GIT克隆VS源码下来,打开解决方案发现引用全部是黄色叹号,无法编译
评论列表

发表评论

评论内容
昵称:
关联文章

The object cannot be deleted because it was not found in the ObjectStateManager
.NET Core创建DbContext报错:Cannot create a DbSet for 'XXX' because this type is not included in the model for the context.
FastReport报错:TfrxReportClass cold not be found!
EFCore删除记录报错:The instance of entity type 'xxx' cannot be tracked because another instance with the same key value for {'isid'} is already being tracked
System.NotSupportedException:“The entity or complex type 'CSFramework.EF.tb_MyUser' cannot be constructed in a LINQ to Entities query.”
Entity Framework(EF):测试DbContext.Remove方法,对象状态管理器(Object State Manager)
HTTP Error 500.31 - Failed to load ASP.NET Core runtime,Microsoft.NetCore.App or Microsoft.AspNetCore.App was not found.
EF调用Oracle报错:System.FormatException:“One of the identified items was in an invalid format.”
The server factory could not be located for the given input: Microsoft.Owin.Host.HttpListener
The Database principal owns a schema in the database
EFCore:Cannot use table 'xxx' for entity type 'xxx' since it is being used for entity type 'xxx' and potentially other entity types
WebApi日期解析错误:The JSON value could not be converted to System.Nullable`1[System.DateTime].
达梦数据库使用 DmBulkCopy 批导数据报错:Operation is not valid due to the current state of the object
The instance of entity type "tb_Inventory" cannot be tracked because another instance with the same key value for {'isid'} is already being tracked
SQL:Cannot resolve the collation conflict (字符集冲突)
No Entity Framework provider found for the ADO.NET provider with invariant name 'System.Data.SqlClient'
Cannot resolve the collation conflict.无法解析等号两边的中文简体和中文繁体字符集
.NETCore WebApi运行报错:System.AggregateException:“Some services are not able to be constructed
Object Collection Editor窗体的Add/Delete按钮不可用
Oracle连接失败:IO错误,The Network Adapter could not establish the connection,供应商代码17002

热门标签
软件著作权登记证书 .NET .NET Reactor .NET5 .NET6 .NET7 .NET8 .NET9 .NETFramework APP AspNetCore AuthV3 Auth-软件授权注册系统 Axios B/S B/S开发框架 B/S框架 BSFramework Bug Bug记录 C#加密解密 C#源码 C/S CHATGPT CMS系统 CodeGenerator CSFramework.DB CSFramework.EF CSFramework.License CSFrameworkV1学习版 CSFrameworkV2标准版 CSFrameworkV3高级版 CSFrameworkV4企业版 CSFrameworkV5旗舰版 CSFrameworkV6.0 CSFrameworkV6.1 CSFrameworkV6旗舰版 DAL数据访问层 Database datalock DbFramework Demo教学 Demo实例 Demo下载 DevExpress教程 Docker Desktop DOM ECS服务器 EFCore EF框架 Element-UI EntityFramework ERP ES6 Excel FastReport GIT HR IDatabase IIS JavaScript LINQ MES MiniFramework MIS MySql NavBarControl NETCore Node.JS NPM OMS Oracle资料 ORM PaaS POS Promise API PSD RedGet Redis RSA SAP Schema SEO SEO文章 SQL SQLConnector SQLite SqlServer Swagger TMS系统 Token令牌 VS2022 VSCode VS升级 VUE WCF WebApi WebApi NETCore WebApi框架 WEB开发框架 Windows服务 Winform 开发框架 Winform 开发平台 WinFramework Workflow工作流 Workflow流程引擎 XtraReport 安装环境 版本区别 报表 备份还原 踩坑日记 操作手册 达梦数据库 代码生成器 迭代开发记录 功能介绍 官方软件下载 国际化 基础资料窗体 架构设计 角色权限 开发sce 开发工具 开发技巧 开发教程 开发框架 开发平台 开发指南 客户案例 快速搭站系统 快速开发平台 框架升级 毛衫行业ERP 秘钥 密钥 权限设计 软件报价 软件测试报告 软件加壳 软件简介 软件开发框架 软件开发平台 软件开发文档 软件授权 软件授权注册系统 软件体系架构 软件下载 软件著作权登记证书 软著证书 三层架构 设计模式 生成代码 实用小技巧 视频下载 收钱音箱 数据锁 数据同步 塑木地板行业ERP 微信小程序 未解决问题 文档下载 喜鹊ERP 喜鹊软件 系统对接 详细设计说明书 新功能 信创 行政区域数据库 需求分析 疑难杂症 蝇量级框架 蝇量框架 用户管理 用户开发手册 用户控件 在线支付 纸箱ERP 智能语音收款机 自定义窗体 自定义组件 自动升级程序
联系我们
联系电话:13923396219(微信同号)
电子邮箱:23404761@qq.com
站长微信二维码
微信二维码