如何让实体框架更新复杂类型?
我正在使用实体框架 (EF) 从存储过程创建复杂类型。最近,存储过程发生了变化(添加了更多返回值。我想更新映射到该存储过程的复杂类型。这可能吗?如果可以,如何实现?我目前正在每次删除我的函数导入和复杂类型存储过程更改,这很可能不是最好的方法。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我找到了另一种方法来做到这一点而不删除复杂类型。您可以更新复杂类型,Visual Studio 将添加任何更改的列。操作方法如下:
应该这样做!
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!
有一种更简单的方法可以实现这一点,请查看此处 SO。它向存储过程添加一些元信息,EF 使用这些信息为您生成适当的返回类型。
存储过程的元信息部分不会被执行,它只是告诉它返回哪些列和数据类型。
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.