尽管未选择该选项,但实体框架仍会导入存储过程

时间:2022-03-14 02:16:49

I've got a database which has lots of tables, views and stored procedures. When I try to Update model from database it takes also a stored procedure, although I didn't asked for it. 尽管未选择该选项,但实体框架仍会导入存储过程 When I compile the code it gives me errors, so I have to manually remove stored procedure from Context file: 尽管未选择该选项,但实体框架仍会导入存储过程

我有一个包含大量表,视图和存储过程的数据库。当我尝试从数据库更新模型时,它也需要一个存储过程,尽管我没有要求它。当我编译代码时它会给我错误,所以我必须从Context文件中手动删除存储过程:

Added part to usings section:
尽管未选择该选项,但实体框架仍会导入存储过程

添加部分使用部分:

Added part to the context file: 尽管未选择该选项,但实体框架仍会导入存储过程

添加了上下文文件的部分:

How to prevent getting that stored procedure?

如何防止获取该存储过程?

2 个解决方案

#1


You can try removing the stored procedure from the model browser for your model. The stored procedure will appear in Function Imports. Now after this, try Ctrl+A in your model and delete all entities and then update your model from the database selecting only tables and see how it goes.

您可以尝试从模型浏览器中删除模型的存储过程。存储过程将显示在“函数导入”中。此后,在模型中尝试Ctrl + A并删除所有实体,然后从数据库中更新模型,仅选择表并查看它是如何运行的。

As far as the namespace error is concerned, try replacing System.Data.Objects with System.Data.Entity.Core.Objects.

就命名空间错误而言,尝试用System.Data.Entity.Core.Objects替换System.Data.Objects。

Hope this helps.

希望这可以帮助。

#2


Solved this problem by opening .edmx file in XML editor and removing all nodes containing sp_rt_Pivot function. Worked well, but seems it's a EF bug.

通过在XML编辑器中打开.edmx文件并删除包含sp_rt_Pivot函数的所有节点来解决此问题。工作得很好,但似乎是一个EF错误。

#1


You can try removing the stored procedure from the model browser for your model. The stored procedure will appear in Function Imports. Now after this, try Ctrl+A in your model and delete all entities and then update your model from the database selecting only tables and see how it goes.

您可以尝试从模型浏览器中删除模型的存储过程。存储过程将显示在“函数导入”中。此后,在模型中尝试Ctrl + A并删除所有实体,然后从数据库中更新模型,仅选择表并查看它是如何运行的。

As far as the namespace error is concerned, try replacing System.Data.Objects with System.Data.Entity.Core.Objects.

就命名空间错误而言,尝试用System.Data.Entity.Core.Objects替换System.Data.Objects。

Hope this helps.

希望这可以帮助。

#2


Solved this problem by opening .edmx file in XML editor and removing all nodes containing sp_rt_Pivot function. Worked well, but seems it's a EF bug.

通过在XML编辑器中打开.edmx文件并删除包含sp_rt_Pivot函数的所有节点来解决此问题。工作得很好,但似乎是一个EF错误。