简体   繁体   English

EF 6删除失败,Insert语句的选择列表包含的项目多于插入列表

[英]EF 6 delete fails with The select list for the Insert statement contains more items than the insert list

My EF Remove fails with the above statement. 我的EF删除失败,并带有上述声明。 The table (Product) has a single primary key (ProductID). 表(Product)具有单个主键(ProductID)。 Running SQL Trace produced the following SQL that causes the failure: 运行SQL跟踪会产生以下导致失败的SQL:

exec sp_executesql N'DELETE [dbo].[Product] WHERE ([ProductID] = @0)',N'@0 int',@0=620895

Full error statement: 完整错误声明:

Msg 121, Level 15, State 1, Procedure t_del_Product, Line 8 The select list for the INSERT statement contains more items than the insert list. 消息121,级别15,状态1,过程t_del_Product,第8行INSERT语句的选择列表包含的项目多于插入列表。 The number of SELECT values must match the number of INSERT columns. SELECT值的数量必须与INSERT列的数量匹配。

Other similar Removes work just fine. 其他类似的删除工作正常。 My EDMX is fully updated against the DataSource (SQL Server 2012) 我的EDMX针对DataSource进行了全面更新(SQL Server 2012)

Any ideas? 有任何想法吗? Anyone? 任何人? Anyone? 任何人? Thanks! 谢谢!

UPDATE: I should have tried this earlier, but I get the same error even with a simple: DELETE FROM Product Where ProductID = 620895 So, it is not EF. 更新:我本来应该尝试过这个,但即使是一个简单的问题我也会得到同样的错误:DELETE FROM Product Where ProductID = 620895所以,它不是EF。

As mentioned in my comment: 正如我的评论所述:

It looks like the sp is being called (possibly) when a delete occurs on dbo.Product and is producing your error. 当在dbo.Product发生删除并且正在产生错误时,看起来(可能)正在调用sp。 Just look on the table and see if there are triggers defined on it. 只需查看表格,看看是否有定义的触发器。

If indeed there is a trigger on the table calling this SP, then this is likely your issue and you should look into fixing the SP. 如果确实在调用此SP的表上有触发器,那么这可能是您的问题,您应该考虑修复SP。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM