3

I'm trying to add a sql (stored) function to Entity Framework, but unsuccessfully. I tried with right clicking on a table in .edmx and "Function Import", but the function is not shown there, although I added it (updated model from the database).

Does anyone have solution for this?

Eedoh
  • 5,818
  • 9
  • 38
  • 62
  • Helio's suggestion to convert to stored procedures is probably the best solution in many situations. Another approach is to hand-code a CreateQuery call as suggested by Evil Pigeon [on this SO post.](http://stackoverflow.com/questions/3500509/calling-user-defined-functions-in-entity-framework-4) – Tim Sep 18 '14 at 22:35

1 Answers1

3

You should be able to simply convert a stored function into a stored procedure in SQL. Although Entity Framework defines stored procedures as functions or lists stored functions under Stored Procedures, stored functions are not compatible with Entity Framework. You can "Update Model from Database..." and add Stored Procedures then right click and add "Function Import..."

Helio
  • 621
  • 1
  • 4
  • 24