开发者

Entity Framework: Generate Database From Model removes Stored Procedures from Model Store

I am using a stored procedure with an EF 4 model.

To accomplish this I'm going through the following steps:

  1. I add the stored procedure to my Model Store by Updating from the database and selecting it.

  2. Added a function import to point to the stored procedure

  3. 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 Generat开发者_如何学Goion Workflow" that is TablePerTypeStrategy but apparently this has the added effect of removing stored procedures from the model store.


I am using model first but also mapping stored procedures to function imports. Unfortunately when I make updates to the model and try to generate the database from the model, it removes my stored procedures and unmaps my function imports.

To get around this, I do an undo after I generate the database from the model on the EDMX (and keep the updated sql script). This updates the database just fine for me and restores my stored procedures and function imports as well.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜