【问题标题】:System.Data.Entity.Infrastructure.DbUpdateExceptionSystem.Data.Entity.Infrastructure.DbUpdateException
【发布时间】:2014-10-31 22:13:23
【问题描述】:

我在 WPF 项目下创建了数据库优先实体数据模型。然后我添加了一个 DataGrid 并将其绑定到模型。我一直在尝试添加 CRUD 功能。

一切都很好,直到我添加了一个按钮并绑定了它的点击事件来保存更新的数据。单击此按钮后,我会收到以下运行时错误。

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

所以我检查了内部异常并得到以下信息:

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'.

StoreGeneratePattern 在哪里,我可以解决这个问题吗?

【问题讨论】:

    标签: c# wpf entity-framework


    【解决方案1】:

    它位于 .edmx 文件中。在该文件中搜索 StoreGeneratePattern。

    当您通过 Visual Studio 的代码创建按钮创建 ADO 模型时,生成的代码是在一些假设的情况下完成的。在这种情况下,它是导致问题的计算列。

    这是一个非常具体的问题,我能够解决并希望回馈。欢迎编辑!

    【讨论】:

      猜你喜欢
      • 2017-12-10
      • 2023-04-08
      • 1970-01-01
      • 1970-01-01
      • 2013-10-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多