Question

In my MVC application I imported a stored procedure as a function import (in EDMX File)

The stored procedure changed (new parameter) but I don't know how to update it.

For now I just deleted and re-add it manually, but I would like to know what's the best way to achieve this.

UPDATE:

I found an option in the update model from database wizar, there is a refresh tab there, but when attempting to refresh, It does not create the new parameter

Was it helpful?

Solution

First, to understand your problem, what you need to know is that the EDMX file is just an XML file that contains 3 different sections:

  • CSDL: Conceptual schema definition language
  • SSDL: Store schema definition language
  • MSL: Mapping specification language

The CSDL contains the entities and relationships that make up your conceptual model. The SSDL describes your DB model and the MSL is the mapping between the 2.

The “Update Model From DB” process will update the SSDL (change everything that is inconsistent with the current DB schema), it will only modify the CSDL in case you’ve added new things to your DB schema.

This is quite a normal behavior since your Conceptual schema may/should differ from your DB schema (unless you want your Domain model to look exactly like a DB model which obviously do not sound as OOP/DDD best practices).

The Function Import mechanism works the same way. As soon as you import a new Stored Procedure, a new FunctionImport Element will be added in the CSDL. This new element will describe the SP including its parameters. As I said, only new things will be added in the CSDL if you run the Update Wizard, that's why if you change any SP parameter in your DB, it won't be changed in the conceptual model.

To force the conceptual model to change, open your EDMX, go in your Model Browser, expand the Function Import entry:

  • If you want everything to be refreshed, simply remove the function and import it again
  • If you want to change input parameters, expand the right function, remove the parameters and update the function
  • If you want to update only the return type, right click on the right function, select update and click on Update
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top