我正在我的应用程序中使用 EF。我尝试将新记录保存\插入到患者视图



我在SQL server中创建了一个视图,然后在visual studio 2012中添加到我的edmx文件中,然后在Postman上进行POST,得到了这个运行时错误。

  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; }
        }
    }

视图上需要一个主键。http://blogs.msdn.com/b/alexj/archive/2009/09/01/tip-34-how-to-work-with-updatable-views.aspx

最新更新