Entity 3.5 structure and display of stored procedure results

Using EF3.5 with Visual Studio 2010 (at the moment it is not possible to upgrade to EF4 - do not ask!).

The desire to create a stored procedure that aggregates some fields from some related tables and materializes the result of the stored procedure as a custom “object”. This custom object will be read-only. I configured a custom object, a stored procedure, and a function import. When I create an Entity project, I get the following:

Error 35 Error 3027:
No mapping specified for the following EntitySet / AssociationSet - MyCustomEntitySet

It looks like he wants to match the table defined for my custom object, however in this case I would not have one since he aggregates the data across several tables (and filters out some unnecessary data).

Is it possible to map a custom object to a stored procedure? Is it possible to ensure that the "Update Model from Database" functionality does not violate the user object or the stored proc / function import mapping?

TIA!

+4
source share
1 answer

We went around this by creating a view in db - the view is never used if you are attached to stored procedures, but it allows you to automatically create the correct mappings in the entity.

As a rule, for fairly direct processes, you can copy / paste sql to generate a view - this saves some time.

+3
source

Source: https://habr.com/ru/post/1339933/


All Articles