asp.net-mvc – 为什么我得到一个“无法更新EntitySet,因为它有一个定义查询…”异常时,试图更新在En
发布时间:2020-07-03 11:31:47 所属栏目:asp.Net 来源:互联网
导读:在使用Entity Framework的LINQ to SQL的帮助下更新时,抛出异常。 System.Data.UpdateException: Unable to update the EntitySet t_emp because it has a DefiningQuery and no UpdateFunction element exists in the Modif
|
在使用Entity Framework的LINQ to SQL的帮助下更新时,抛出异常。 System.Data.UpdateException: Unable to update the EntitySet 't_emp' because it has a DefiningQuery and no <UpdateFunction> element exists in the <ModificationFunctionMapping> 更新的代码是: public void Updateall()
{
try
{
var tb = (from p in _te.t_emp
where p.id == "1"
select p).FirstOrDefault();
tb.ename = "jack";
_te.ApplyPropertyChanges(tb.EntityKey.EntitySetName,tb);
_te.SaveChanges(true);
}
catch(Exception e)
{
}
}
为什么我收到此错误? 解决方法问题出在表结构中。为了避免错误,我们必须在表中创建一个主键。之后,更新edmx。问题将得到解决(编辑:日照站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
推荐文章
站长推荐
- QueryString与ASP.NET MVC 6锚点标签助手
- 将搜索框添加到ASP.Net动态数据列表页面
- asp.net-mvc – ASP.NET MVC WebSite中的ERR_EMP
- asp.net核心 – 如何排除在ASP.NET Core中发布文
- 在IIS / ASP.Net中的.NET 1.1应用程序中创建.NET
- asp.net – Orchard CMS如何进行日志记录?
- ASP.NET Webdeploy失败;项目中不存在AddSchedule
- ASP.NET MVC AJAX文档在哪里?
- asp.net – ASP MVC用户配置文件
- ASP.NET Core 1.0 ConfigurationBuilder().AddJs
热点阅读
