EF代码优先 - 映射存储过程 [英] EF Code-First - Mapping stored procedures

查看:113
本文介绍了EF代码优先 - 映射存储过程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在我的数据库模型中实现嵌套集。为了方便使用,我想在我的树节点上创建插入/更新/删除操作的存储过程,以保持我的树处于有效状态。



是否可以在当前版本的代码优先模型中创建存储过程的映射?我的意思是,当例如将新的实体添加到dbcontext时,我的存储过程将被调用。

解决方案


代码首先在实体框架不支持存储过程
默认值。因为没有设计师,我们甚至不能将我们存储的procs
映射到实体。有许多情况我们已经看到我们在哪里
绑定使用存储过程进行任何数据库修改
(插入/更新/删除)。


您可以使用下面的链接和/或谷歌您的问题找到更多的解决方案。



使用实体首先使用存储过程的框架代码代码首先4.1:使用存储过程插入数据


I'm trying to implement nested sets in my database model. To make it easy to use I would like to create stored procedures for insert/update/delete operations on my tree nodes to keep my tree in a valid state.

Is it possible to create mapping of the stored procedures in the current version of code-first model? I mean that my stored procedures will be called when for example, new entity will be added to the dbcontext.

解决方案

Code First in Entity Framework does not support Stored Procedure by default. As there is no designer we cannot even map our stored procs to the entity. There are a many scenario we have seen where we are bound to use stored procedure for any database modifications (insert/update/delete).

You can use below links, and/or google your question to find more solutions.

Using Entity Framework Code First with Stored Procedures AND Code First 4.1 : Using Stored Procedure to Insert Data

这篇关于EF代码优先 - 映射存储过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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