MVC 4.5与实体框架 [英] MVC 4.5 with entity framework

查看:89
本文介绍了MVC 4.5与实体框架的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,



我正在开展项目,我们将使用MVC 4.5和Entity Framework6。



我脑子里有一些疑问;

1.我们可以使用存储过程和实体框架吗?因为有一种情况我们插入

并在单击按钮上更新多个表中的数据,这可以通过数据库上的一次点击使用

存储过程轻松实现。如果我们不使用存储过程,那么我们必须多次使用
命中数据库。

在这种情况下,实体框架中是否有更好的替代方案。



2.我们可以在服务器上传我们的项目而不发布它。因为在我们的情况下,经常会发生小的变化,我们必须在服务器上多次上传一个页面才能进行一次小的更改。如果没有,那么请建议一个更好的选择。



问候,

Ashish verma

解决方案

1.yes ..你可以在实体框架工作中使用存储过程。但是在简单的CRUD操作的情况下,实体方法更有效



使用存储过程的实体框架CRUD操作 [ ^ ] br />






2.yes ..您可以将该特定文件仅复制到Web服务器中

1。通常我使用通用存储库(搜索存储库模式),您可以在存储库中实现InsertOrUpdate方法,并使其在每个实体中可用,您不需要需要为实体创建一个SP 。



2。您可以发布文件并查找上次编辑时间大于服务器版本的文件,更改.cshtml / .config / .js文件的示例,您可以上传修改后的文件,如果您更改了模型/控制器,则只需上传包含该特定类的.dll


Hello,

I am working on project in which we are going to use MVC 4.5 and Entity Framework6.

There are some doubts in my mind that are;
1. Can we use stored Procedure with Entity framework. Because there is a scenario where we insert
and update data in multiple tables on single button click which could easily achieved using a
stored procedure on one hit on the Database. If we do not use stored procedure then we have to
hit database many times.
Is there any better alternative in entity framework for this scenario only.

2. Can we upload our project on the server without publishing it. Because in our case small
changes frequently take place and we have to upload a single page many times on the server for
a small change. If not then please suggest a better alternative of it.

Regards,
Ashish verma

解决方案

1.yes..you can use stored procedure in entity frame work.but in the case of simple CRUD operations,entity method is more efficient

Entity Framework CRUD Operations Using Stored Procedures[^]



2.yes..you can copy that particular file only n paste in web server


1. usually i use a generic repository (search for repository pattern) you could implement a InsertOrUpdate method in your repository and make it available across every entity, you don't need to create one SP for entity.

2. you can publish your files and look for the ones that have last edit time grater than the version of the server, for example for changes on .cshtml / .config / .js files you can upload the modified file, if you changed the model / controller you need too upload only the .dll that contains that specific class


这篇关于MVC 4.5与实体框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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