I have some stored procedures mapped in Entity Framework using Database First. It creates strongly typed methods that you can call to run the stored procedures. I've run into a significant problem, however, in that I don't see any way to call these methods it created with the default parameters defined in the stored procedures. This means:
a) I have to manually add the default parameters to the method calls, which is brittle, if the default parameter value were to ever change.
b) Write method overloads by hand. This basically eliminates the benefit of generating a model from the database in the first place.
Does anyone know if there is a better solution to this problem?
Thanks.
Entity Framework has the ability to automatically build native commands for the database based on your LINQ-to-Entities or Entity SQL queries, as well as build the commands for inserting, updating, and deleting data. You may want to override these steps and use your own predefined stored procedures.
Store node and then open the Stored Procedures node. Then right-click the GetCourses stored procedure and select Add Function Import. In the Add Function Import dialog box, under Returns a Collection Of select Entities, and then select Course as the entity type returned. When you're done, click OK.
As of Jan 2013, there's no supported way to do have the Entity Framework do this.
I have opened a feature request here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With