Back to FAQs

Batch Import of Stored Procedures in Entity Framework 5.0

Prior to Entity Framework 5.0, you had to manually import the stored procedure as a function. . Now with Entity Framework 5.0, you can import multiple stored procedures automatically as functions, when you add an entity data model or update it. For example, select multiple stored procedures and functions in Entity Data Model Wizard then select checkbox 'Import selected stored procedures and functions into the entity model' and then click Finish:

Entity Framework 5.0 Tutorial

Now, open the Model Browser and check that it has automatically created the function imports for all these procedures and functions, and has also created complex types as their return type:

Entity Framework 5.0 Tutorial

You can edit function import by right clicking on procedure name and selecting Edit. You can change the return type as entities or as Scalars.

Once you edit function import then you should make sure that it will not give any run time errors. This can be accomplished by right clicking on procedure and selecting 'Validate':

Entity Framework 5.0 Tutorial

So in this way you can batch import stored procedures and functions.