Entity Framework SQL View

  • Thread starter Thread starter Patrick
  • Start date Start date
P

Patrick

Hi,

I am using SQL Views to populate my entities via the Entity Framework.

I now want to be able to save changes to my entities. However, I get the
following exception

Unable to update the EntitySet 'InvoiceItem' because it has a DefiningQuery
and no <UpdateFunction> element exists in the <ModificationFunctionMapping>
element to support the current operation.

Is there a way to use my sql view to save my entity?

Thanks heaps
 
Patrick said:
Hi,

I am using SQL Views to populate my entities via the Entity Framework.

I now want to be able to save changes to my entities. However, I get the
following exception

Unable to update the EntitySet 'InvoiceItem' because it has a
DefiningQuery
and no <UpdateFunction> element exists in the
<ModificationFunctionMapping>
element to support the current operation.

Is there a way to use my sql view to save my entity?

What that is telling you is you need a Stored Procedure mapped to the
UpdateFunction to update the entity on the model.

<http://msdn.microsoft.com/en-us/library/cc716696.aspx>

<http://blogs.infosupport.com/blogs/...procedures-with-ADO.NET-entity-framework.aspx>

I am sure you can find more information on this by using Google.
 
Thanks for the reply.

However, I am quite familiar with linq and how function mappings work etc.

I probably should have been more clear that I don't want to use function
(sproc) mappings. I want linq to utilise the view to perform the relevant
CRUD not sprocs. Do you know how to get this to work?

Thanks heaps,
Patrick
 
Patrick said:
Thanks for the reply.

However, I am quite familiar with linq and how function mappings work etc.

I probably should have been more clear that I don't want to use function
(sproc) mappings. I want linq to utilise the view to perform the relevant
CRUD not sprocs. Do you know how to get this to work?

I don't think you can do it other than the method EF is telling you that you
can do CRUD operations on an ORM virtual database model entity for a SQL
Server table view. You have to remember that you are not going against a SQL
Server database and table directly, and you are going up against a virtual
database represented in the model.

If you find something on how to do it the way you are wanting to do it, post
back the solution. That's why I use table per class, table per concrete
class etc and avoid sporcs and now it looks like SQL Server table views too
in defining the model.
 
Back
Top