I am using EF with a SQL Server database. I created a view and an Instead Of Insert
trigger for that view which looks like this:
insert into Target (value, someFk)
select value, 4 from inserted
select id from Target where @@ROWCOUNT > 0 and id = scope_identity()
I mapped the view into an EF edmx. When I try to add an entity I get the following exception when I call SaveChanges()
:
Unable to update the EntitySet 'TargetView' because it has a DefiningQuery and no element exists in the element to support the current operation.
The view has an identity column marked in the mapping.
Any suggestions?