Unable to update the EntitySet 'XXX' because it has a DefiningQuery and no element exists in the element to support the current operation.

在使用MVC框架,向数据库中的表格插入一条数据时,出现以下问题:

Unable to update the EntitySet '***'because it has a DefiningQuery and no element exists in the element to support the current operation.

注:上面*部分标示你要插入的数据库实体类名。

这个问题是在使用AdO.NET Entity Framework的时候,你使用的“XXX”这张表在数据库没有定义主键,只要设置了主键,就不会出现这个异常或这个错误了。

posted @ 2012-09-05 13:39  @大龙哥  阅读(1980)  评论(0编辑  收藏  举报