如何自动更新实体框架功能导入 [英] How can I automatically Update Entity Framework Function Imports

查看:168
本文介绍了如何自动更新实体框架功能导入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用实体框架来调用我的存储过程。我正在使用函数导入向导来完成该过程,以创建函数导入和复杂类型。



我遇到的问题是我想找到一种方式以便轻松刷新我所有的复杂类型。



当今天有存储过程更改时,我的过程是:



1。)使用EF更新向导刷新存储过程。



2。)转到模型浏览器中的每个函数导入,然后单击编辑。



3。)点击按钮更新复杂的类型。



4。)手动重复这个过程,为我所有的100+我的功能进口。



这个更新过程在这里很好解释:
http://blogs.msdn.com /b/nihitk/archive/2010/04/23/ado-net-entity-designer-in-vs-2010-stored-procedure-return-type-shape-sensing.aspx

$有没有人知道如何通过命令行或某种宏来自动化。我不需要这样做是构建过程的一部分。

解决方案

查看附带的EdmGen命令行工具实体框架。找出您需要生成包含您的函数导入的EDMX的命令行开关(很可能还有很多其他的东西)。



然后写一个小的命令行程序,使用XDocument和LINQ to XML来读取您想要的生成的EDMX的XML元素,然后使用相同的技术来覆盖真正的EDMX中的元素。



如果您希望这个过程成为构建的一部分(它会减慢事情),将这两个命令添加到项目的项目属性中的Pre-build事件命令行设置。



其他开发人员和构建服务器还需要一个编译版本的新的合并命令,可以在某处调用。


I'm using entity framework to call my stored procedures. I'm going through the process using the function import wizard as to create function imports and complex types.

The problem I'm having is I would like to find a way to easily refresh all of my complex types.

When there are stored procedure change today, my process is to:

1.) Refresh stored procedures using the EF update wizard.

2.) Go to each function import in the model browser and click edit.

3.) Click the button to update complex type.

4.) Manually repeat this process for all 100+ of my function imports.

This update process is very well explained here: http://blogs.msdn.com/b/nihitk/archive/2010/04/23/ado-net-entity-designer-in-vs-2010-stored-procedure-return-type-shape-sensing.aspx

Does anyone know how this can be automated either via a command line or through some sort of macro. I don't need this to be part of a build process.

解决方案

Check out the EdmGen command-line tool that comes with Entity Framework. Figure out what command line switches you need to generate an EDMX that contains your function imports (and quite likely a lot of other stuff).

Then write a small command-line program that uses XDocument and LINQ to XML to read the XML elements you want out of the generated EDMX and then uses the same technique to overwrite the ones in your real EDMX.

If you want this process to be part of the build (it will slow things down though) add these two commands to your project's Pre-build event command line settings in project properties.

Other developers and the build server would also need a compiled version of your new merging command checked-in somewhere to call.

这篇关于如何自动更新实体框架功能导入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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