I am using a stored procedure with an EF 4 model.
To accomplish this I’m going through the following steps:
-
I add the stored procedure to my Model Store by Updating from the database and selecting it.
-
Added a function import to point to the stored procedure
-
The stored procedure returns the result of a query joining multiple tables etc so in the “Returns Collection Of” area I specify a Complex Type and use the Get Column Information button below to generate the complex type returned.
Here is where my issue arises: when I use the “Generate Database From Model” option, it removes the stored procedure mapping from the Model Store.
My question is:
How can I use the “Generate Database From Model” option but ignore the Stored Procedures mapping?
In the model properties there is a “Database Generation Workflow” that is TablePerTypeStrategy but apparently this has the added effect of removing stored procedures from the model store.
These two approaches should not be used together! Use either database first (Update model from database) or model first (Generate database from model). I’m even surprised that it didn’t delete your stored procedures in the database as well.
When you select Generate database from model it deletes whole storage description and mapping from your EDMX and generates a new one.