How Do I Get Entity Framework To Update Complex Types?

后端 未结 2 1786
旧巷少年郎
旧巷少年郎 2021-01-30 12:56

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 upd

相关标签:
2条回答
  • 2021-01-30 13:36

    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:

    1. Open your .edmx file and go to the model browser.
    2. If your stored proc changed, right-click on any white area in the model browser and select Update Model From Database, click "Finish". This will refresh your stored procedure.
    3. Now drill down into XModel.edmx > XModel > EntityContainer:XEntities > Function Imports (X is your entity name) and right-click the one that you need to update. Select Edit.
    4. Click "Get Column Information". Now, next to the Complex Type radio button, there is a Update button. Press this to update your complex type and then press the OK button.

    That should do it!

    0 讨论(0)
  • 2021-01-30 13:37

    There is an easier way to achieve that, look here at SO. It adds some meta information to the stored procedure, which the EF uses to generate the appropriate return type for you.

    The meta information part of the stored procedure is not executed, it just tells about which columns and datatypes it returns.

    0 讨论(0)
提交回复
热议问题