DTig
DTig

Reputation: 1084

How can I automatically Update Entity Framework Function Imports

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.

Upvotes: 10

Views: 2951

Answers (1)

DamienG
DamienG

Reputation: 6665

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.

Upvotes: 2

Related Questions