【问题标题】:I'm using EF in my application. I try to save\insert a new record to a Patient View我在我的应用程序中使用 EF。我尝试将新记录保存\插入到患者视图
【发布时间】:2015-03-03 11:39:25
【问题描述】:

我在 SQL Server 中创建了一个视图,然后在 Visual Studio 2012 中将其添加到我的 edmx 文件中,然后我在 Postman 上发布它并收到此运行时错误。

  Unable to update the EntitySet 'ViewPatient' because it has a DefiningQuery and no <InsertFunction> element exists in the <ModificationFunctionMapping> element to support the current operation.




//Controller action code   namespace MvcWebAPI.Models
  {
        using System;
        using System.Collections.Generic;

        public partial class ViewPatient
        {
            public int PatientID { get; set; }
            public int MedicationID { get; set; }
            public int GPID { get; set; }
            public string Firstname { get; set; }
            public string Surname { get; set; }
            public System.DateTime DOB { get; set; }
            public string Medication { get; set; }
            public string Alergies { get; set; }
            public string MedicationHistory { get; set; }
        }
    }

【问题讨论】:

  • 您有问题吗?
  • 很明显。我在 SQL Server 中创建了一个视图,然后在 Visual Studio 2012 中添加到我的 edmx 文件中,然后我在 Postman 上发布它并得到了这个运行时错误。我将如何解决它。
  • 为了将来参考,您可能想在提交时提出您的问题。要回答您的评论,请尝试阅读提供给您的消息并根据它进行调试:Unable to update the EntitySet 'ViewPatient' because it has a DefiningQuery and no &lt;InsertFunction&gt; element exists in the &lt;ModificationFunctionMapping&gt; element to support the current operation.
  • 我已经在我的提交中询问了它阅读第一行。我已阅读它,我正在询问如何解决它。
  • 您的原始帖子中没有问题,只有陈述。错误消息清楚地说明了问题所在以及如何解决问题。如果您无法阅读错误消息并在调试中使用它们,则需要回到 101 的开发并重新开始。

标签: sql-server entity-framework visual-studio-2012 asp.net-web-api


【解决方案1】:
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-08-21
  • 1970-01-01
  • 1970-01-01
  • 2015-05-28
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多