在代码优先方法中使用存储过程? [英] Using stored procedures in code-first approach?

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

问题描述

我在Entity Framework v6.1.3中使用代码优先方法.

I am using code-first approach in Entity Framework v6.1.3.

我的问题是:我使用的是代码优先方法,我是否还应该通过实体注入存储过程,还是应该进入数据库并在其中创建存储过程?

My question is: I am using a code-first approach, should I also inject the stored procedures through my entities or should I just go to my database and create a stored procedure there?

解决相同问题的最佳方法是什么?

What will be the best method to address the same?

推荐答案

您首先使用代码,请不要创建存储过程.切换到ORM的目的是摆脱手动将代码直接直接添加到SQL中的过程.实体框架提供了一种使用现有存储过程的方法,因此您不必重写整个数据库,而应远离创建新的存储过程,并将业务逻辑始终保留在应用程序中.

You are using code first, do not create stored procedures. The point of switching to a ORM is to move away from manually adding code directly into SQL. Entity framework provides a way to use existing stored procedures so you don't have to rewrite an entire database but you should move away from creating new stored procedures and keep your business logic where it has always belonged, in the application.

这篇关于在代码优先方法中使用存储过程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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