简体   繁体   English

System.Data.Entity.Infrastructure.DbUpdateException

[英]System.Data.Entity.Infrastructure.DbUpdateException

I created a Database First Entity Data Model under a WPF Project.我在 WPF 项目下创建了一个数据库优先实体数据模型。 I then added a DataGrid and Binded it to the model.然后我添加了一个 DataGrid 并将其绑定到模型。 I've been trying to add CRUD capability.我一直在尝试添加 CRUD 功能。

All was good until I added a Button and tied its click event to save the updated data.一切都很好,直到我添加了一个 Button 并绑定了它的点击事件来保存更新的数据。 Once I clicked on this I'd get the following runtime error.单击此按钮后,我会收到以下运行时错误。

 System.Data.Entity.Infrastructure.DbUpdateException: An error occurred while updating the entries. See the inner exception for details.

So I checked the inner exception and got the following:所以我检查了内部异常并得到以下信息:

 System.Data.Entity.Core.UpdateException: An error occurred while updating the entries. See the inner exception for details.—> System.NotSupportedException: Modifications to tables where a primary key column has property 'StoreGeneratedPattern' set to 'Computed' are not supported. Use 'Identity' pattern instead. Key column: 'Symbol_and_BenchmarkID'. Table: 'BenchMarkModel.Store.Weights'.

Where is StoreGeneratePattern so I can fix this? StoreGeneratePattern在哪里可以解决这个问题?

Its located in the .edmx file.它位于 .edmx 文件中。 Search for the StoreGeneratePattern in that file.在该文件中搜索 StoreGeneratePattern。

When you create an ADO model through visual studio's code creation buttons, the code that is generated is done so with a few assumptions.当您通过 Visual Studio 的代码创建按钮创建 ADO 模型时,生成的代码是在一些假设下完成的。 In this case the its your computed column thats causing the problem.在这种情况下,它是导致问题的计算列。

This was a very specific issue that I was able to solve and wanted to give back.这是一个非常具体的问题,我能够解决并希望回馈。 Edits welcome!欢迎编辑!

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

相关问题 System.Data.Entity.Infrastructure.DbUpdateException问题 - System.Data.Entity.Infrastructure.DbUpdateException Issue 发生System.Data.Entity.Infrastructure.DbUpdateException - System.Data.Entity.Infrastructure.DbUpdateException occurred MVC EF-System.Data.Entity.Infrastructure.DbUpdateException - MVC EF - System.Data.Entity.Infrastructure.DbUpdateException 如何解决 System.Data.Entity.Infrastructure.DbUpdateException - How to solve System.Data.Entity.Infrastructure.DbUpdateException 递归树方法上的System.Data.Entity.Infrastructure.DbUpdateException - System.Data.Entity.Infrastructure.DbUpdateException on recursive Tree method 将数据添加到数据库(错误:System.Data.Entity.Infrastructure.DbUpdateException) - Adding Data to Database (Error: System.Data.Entity.Infrastructure.DbUpdateException) EntityFramework.dll 中发生“System.Data.Entity.Infrastructure.DbUpdateException” - 'System.Data.Entity.Infrastructure.DbUpdateException' occurred in EntityFramework.dll 如何避免System.Data.Entity.Infrastructure.DbUpdateException - How to avoid System.Data.Entity.Infrastructure.DbUpdateException 发生类型为“ System.Data.Entity.Infrastructure.DbUpdateException”的异常 - An exception of type 'System.Data.Entity.Infrastructure.DbUpdateException' occurred 类型为“ System.Data.Entity.Infrastructure.DbUpdateException”的异常 - An exception of type 'System.Data.Entity.Infrastructure.DbUpdateException'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM