开发者

How to avoid trying to update a view in the Entity Framework

开发者 https://www.devze.com 2022-12-21 00:03 出处:网络
I have an Entity Framework project, and it imports a read-only view as one of the entities.This view is related to other entities, and when I attempt to update those entities, it tries to update the v

I have an Entity Framework project, and it imports a read-only view as one of the entities. This view is related to other entities, and when I attempt to update those entities, it tries to update the view also. I get the error:

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

开发者_运维问答

How can I tell the entity framework to not to try to update that entity?

Thanks.


You could always implement insert & update stored procedure for the table that corresponds to the read only view and then configure EF to use the stored procedures. Then you simply perform no action in the stored procedures.

Here is an example of using stored procedures with EF.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号