存储过程和更新EDMX [英] Stored Procedures and updating EDMX

查看:169
本文介绍了存储过程和更新EDMX的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在存储过程和EDMX方面遇到了无尽的问题。我创建了一个过程,从数据库更新了模型,并且一切正常。然后,我删除了一个列,并在存储过程中添加了一个新列。我更新了模型,但EDMX似乎没有刷新proc定义。



我删除了proc,并进行了更新,但必须手动删除所有引用到过程。我最终只是重命名proc并通过模型更新从数据库中导入。



我也遇到了同样的问题。添加了新列,并重命名了现有列。我通过数据库中的更新模型刷新了EDMX,但是EDMX没有任何更改,显然在运行时,它失败了。如何使用Entity Framework更新存储过程?





我删除了proc,重新生成了模型,删除了proc的'cs'文件,进行了编译,然后将过程添加到了数据库中再次,重新生成模型,然后砰!它将相同的模型添加3次,只有最后一个正确。为什么它会一直带回旧版本?

解决方案

(此解决方案适用于EF6。我没有在其他EF中尝试过






转到模型浏览器。
MyStoreProc是存储过程的名称(例如)。 MyStoreProc将出现在3个地方。


  1. 第一名-在Complex Types->下,作为MyStoreProc_result

  2. 第二名-Under函数导入->为MyStoreProc

  3. 第三名-Under存储的
    Procdures /函数->作为MyStoreProc

从模型中删除所有三个。
保存edmx(在窗口中单击,然后单击ctrl + S)。然后右键单击并单击从数据库更新模型。然后添加更新的存储过程并再次保存。



已解决,没有任何麻烦:)


I have had endless issues with stored procedures and EDMX. I created a procedure, updated the model from the database, and all worked. I then removed a column and added a new one in the stored procedure. I updated the model, but the EDMX didn't seem to refresh the proc definition.

I dropped the proc, and did an update, but manually had to delete all references to the proc. I ended up just renaming the proc and importing via model update from database.

I just had the same issue. Added a new column, and renamed an existing column. I refreshed the EDMX via update model from database, but there were no changes to the EDMX, and obviously at run time, it fails. How should a stored procedure update be done with Entity Framework?

I removed the proc, regenerated the model, deleted the 'cs' files for the proc, compiled, then added the procedure to the database again, regenerated the model, and bang! It adds the same model 3 times, with only the last one being right. Why does it keep bringing back the old versions?

解决方案

(This solution is for EF 6. I have not tried in other EF versions. It works nice.)


Go to Model browser. MyStoreProc is the name of the stored procedure (as an example). MyStoreProc will appear in 3 places.

  1. 1st place- Under Complex Types-> as MyStoreProc_result
  2. 2nd Place- Under Function Imports -> as MyStoreProc
  3. 3rd Place - Under Stored Procdures/ Functions -> as MyStoreProc

Delete all three from model. Save the edmx (by clicking in the window then ctrl+S). Then right click and click update the model from database. Then add the updated stored procedure and Save again.

Solved without any hassle :)

这篇关于存储过程和更新EDMX的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆