实体框架:从模型生成数据库从模型存储中删除存储过程 [英] Entity Framework: Generate Database From Model removes Stored Procedures from Model Store

查看:140
本文介绍了实体框架:从模型生成数据库从模型存储中删除存储过程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用具有EF 4模型的存储过程。



要完成此操作,我将执行以下步骤:


  1. 我将存储过程从数据库中更新并将其添加到我的模型存储中。


  2. 添加了一个函数导入以指向存储过程


  3. 存储过程返回查询加入多个表的结果等等,在中返回集合区域我指定一个复杂类型,并使用获取列信息按钮以生成返回的复杂类型。


这里是我的问题出现的地方:当我使用从模型生成数据库选项时,我们的问题是:



>如何使用从模型生成数据库选项,但忽略存储过程映射?



在模型属性中有一个数据库生成工作流那就是TablePerTypeStrategy,但是显然这具有从模型存储中删除存储过程的附加效果。

解决方案

这两种方法不能一起使用!首先使用数据库(从数据库更新模型)或模型(从模型生成数据库)。我甚至不惊讶,它也没有删除数据库中的存储过程。



当您从模型中选择生成数据库时,将删除整个存储描述和映射您的EDMX并生成一个新的。


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 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.

这篇关于实体框架:从模型生成数据库从模型存储中删除存储过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆