Maybe I miss something here but I don't think so.
I have an entity model and it holds sql server views as well. When I was working with my entity, I noticed something like following method;
HubEntities _entities = new HubEntities();
_entities.vw_AccommPropertiesFullWeb.AddObject(...
vw_AccommPropertiesFullWeb
here is a view.
How can it be possible to add a new view to a view? Does EF guys did it on purpose or it is something which is misconfigured?
If you import SQL View to the model it is always represented as DefiningQuery
which is by definition read only. The only way to make it writable is implementing stored procedures and map them to Insert
, Update
and Delete
operations of the entity type.
The workaround is mapping view in the way that EF will believe that it is a table. It requires:
INSTEAD OF
triggers for modification operations or it cannot use joins, union, computed columns, aggregations or anything else unless columns resulting from these operations are marked as computed in EF (database views allows inserting and updating columns only from base table).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.