I'm using the Entity Framework (EF) to create a complex type from a stored procedure. Recently, the stored procedure changed (more return values were added. I would like to update the complex type that maps to this stored procedure. Is this possible and if so, how? I am currently deleting my function import and complex type each time a stored procedure changes, which is most likely not the best approach.
On the designer surface, select one or more properties (excluding navigation properties) of an entity, then right-click and select Refactor -> Move to New Complex Type. A new complex type with the selected properties is added to the Model Browser. The complex type is given a default name.
Update Objects in Entity Framework 4.0First retrieve an instance of the entity from the EntitySet<T> (in our case ObjectSet<Customer>), then edit the properties of the Entity and finally call SaveChanges() on the context.
Go to "Model Browser" > "Function Imports" > find the desired stored procedure class > right click and click on "Edit" In "Edit Function Import" form, in "Returns a Collection Of" section, click on "Update" button. Click "OK" to finish the refresh.
I found another way of doing this without deleting the complex type. You can update your Complex Type and Visual Studio will add any changed columns. Here's how:
That should do it!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With