Updating a stored procedure in entity framework 3.5

I am using .NET 3.5 SP1, VS 2008 with an entity infrastructure. I originally added a stored procedure to my model, which took 2 parameters. Later I changed sproc to just take 1 parameter. I ran the menu item Update Model From Database and confirmed that my sproc was listed on the Refresh tab. The wizard finished, cleaned and rebuilt the solution, and the model never changed the signature of sproc.

Why is it not updating? Does the upgrade model from the database work? Am I missing something? Thank.

+50
visual-studio-2008 stored-procedures entity-framework
Feb 14 '11 at 17:31
source share
8 answers

I saw two problems updating the stored procedure after adding it to the entity infrastructure:

  • The function import created for calling SPROC has not been updated (invalid, outdated parameters)
  • The complex type created for the SPROC result set has not been updated (invalid, obsolete fields)

EDMX model update (function import)

  • Open the .edmx file (in the GUI designer).
  • Right-click in some open space and select "Update Model From Database."
  • Click "Finish" (if possible) in the pop-up window. Your SPROC signature must be updated (along with any Import functions).

Updating a complex type of stored procedure

  • open the Model Browser "window while you open .edmx.

  • Expand the ContentModel , EntityContainer: ... , and then the Import Function nodes. Locate the import function for the stored procedure and double-click . The same window that you used to create it will open, but is now filled with its data.

  • Click the Get Column button (look at the grid below the button to see what will be changed).

  • Click the Refresh button next to the "Complex" radio button.

  • Click OK , and the complex type for your result set should be updated.

+125
Apr 08 2018-12-12T00
source share

You do not need to edit edmx / xml. DOING SO:

When you enter a stored procedure in EDMX (I'm talking about one that returns a result set, but it will be a similar process), 3, not 1, the elements are created, and this is the source of the problem. (*** The second source of the problem is that you must explicitly SAVE after deleting objects before re-importing the objects, otherwise the re-imported objects will encounter something that was not really deleted (by saving) from edmx.

SO! Do it:

In the model browser, usually on the left, insert the name of your stored procedure in the search field, press "Enter" (or search). It lands in the first case - probably the stored procedure itself. Right click and uninstall. Now return the cursor to the search field β†’ press enter or search again. You will now land on the import function. Right click and uninstall. Do the same for the third time - it lands on a complex type representing the result set. Delete it. Now you have finished NOT !!!!!. You need to save what you just did so that the records are written (unwritten) in edmx.

Now go back to the stored procedure (updated model / select the stored procedure). NOW CLICK TO SAVE.

This will work every time. The key is, when using the model browser, to look for ALL instances of the stored procedure name that appear in the model browser, and because of this, it is better not to fuss with the default naming conventions. The second key is SAVE after completing any step.

+13
Sep 10 '15 at 15:27
source share

If you need to change the column data types in the result set -> at the beginning of the storage process, add set fmtonly off

Then use Model Browser β†’ Import Functions β†’ Edit Proc Page β†’ Get Column Information β†’ Update Button

This is how Neil does it :)

+5
Jan 08 '15 at 19:17
source share

This required a lot of manual editing in XML and a couple of restarts of Visual Studio, but I was finally able to make VS forget the previous signature. Then I just used a regular EF master to add it back, and it worked fine.

+1
Feb 14 '11 at 20:52
source share

if you change the signature of the stored process, you will need to update any complex type created in the model using the import function.

+1
May 26 '11 at 2:16
source share

You must delete and add stored procedures back because the entity infrastructure must generate a new definition for your procedure. I think you need to re-import the function.

Basically, if you changed the logic of the procedure, and not the return type or signature, you do not need to add it again. It will work fine, but if you change the return type or the ef signature, you need to generate and map it to a new definition that works like this.

0
Feb 14 '11 at 17:37
source share

Had a similar problem in EF4 where it is not possible to update individual sps, this meant that when you click the update in the update wizard, but it does not work reliably. I had to remove complex types for return values ​​in the model browser, as well as import the function. Then go to the edmx file using an XML editor and remove the link to the saved proc (could not find a way to do this in the model browser). Then re-add sps.

0
Aug 13 '14 at 10:14
source share

You can also erase all SP evidence in the following places; abstract files can be found in the model explorer when opening the .edmx file:

  • YourModel> Complex types;
  • YourModel> Import Functions;
  • YourModel.Store> Stored Procedures / Functions.

After removing it, you can add it without any problems.

0
Apr 28 '15 at 13:08
source share



All Articles