什么时候应该使用实体框架? [英] When should entity framework be used?

查看:66
本文介绍了什么时候应该使用实体框架?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Entity Framework的新手,当然,关于目标用例,我在SOF上发现了几个问题。

I'm new to Entity Framework and, of course, I have found few questions on SOF with regards to target use-cases.

让我给您一些信息。我不会与其他数据库供应商或不同数据库打交道;一个,也是唯一一个,SQL Server 2008和数据库的表少于30个。我真的需要重做并使用Entity Framework吗?

Let me give you some information. I'm not dealing with different database vendors or different databases; one, and only one, SQL Server 2008 and the database has less than 30 tables. Do I really need to redo things and go with Entity Framework?

编辑:

感谢James的修复我的问题。因此,我假设使用EF会增加开销,并且会在后台执行某些我不知道的工作。这是MS的工作风格,所以我想我的下一个问题是:

Thanks to James for fixing my question. So I'm assuming using EF adds up overhead and does some work in background which I won't know. This is MS working style so I guess my next questions are:


  1. 它也会影响性能吗?

  1. Does it affect performance as well?

是否支持hierarchyid数据类型?

Does it support hierarchyid data type?


推荐答案

使用实体框架(或任何其他Object-Relational-Mapper,例如LINQ to SQL,NHIbernate等)的主要原因是为了简化应用程序中的数据访问。借助EF,您只需将新值分配给.NET对象即可获得通过LINQ查询和简单更新的强大功能,而无需自己编写任何SQL代码。

The main reason for using entity framework (or any other Object-Relational-Mapper such as LINQ to SQL, NHIbernate etc.) is to get easier data access in your application. With EF you gain access to the power of querying through LINQ and simple updating by just assigning the new values to a .NET object, without the need to ever write any SQL code yourself.

在我有现有数据库可建立的情况下,我个人将EF Code First和EF Migrations用于绿色领域开发和LINQ to SQL。

Personally I use EF Code First with EF Migrations for green field development and LINQ to SQL in the cases where I have an existing database to build upon.

这篇关于什么时候应该使用实体框架?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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