My organization is currently using a codegen framework (.nEtTiers) which automatically maps custom stored procs which follow a certain convention into “get” methods in the domain model that have the same signature as a proc. So, for example, if I have a Customer table, and I have a stored proc sp_custom_Customer_GetBySalesAmount(@salesAmount), then the framework will create a GetBySalesAmount(salesAmount) in the .NET provider that is generated for Customer.
I know that EF supports stored procs for CRUD operations on entities. But does it have any kind of support for custom stored procs that are mapped to getters? My org wants to start moving in the direction of using EF, and being able to support this would make the transition a lot smoother.
EF with EDMX supports stored procedures mapping – it is called function import. Function import is added to context class (not to entity class) because modern EF (4.x or newer) takes little bit different approach where entity should not be dependent on the persistence layer – those entities are called POCOs.
Stored procedure mapping can be little bit tricky if your procedures contains some complexities because not everything is supported in EF. For example TVP are not supported and only EF with .NET 4.5 will support multiple result sets returned from the procedure.