为什么ADO.NET而不是实体框架 [英] Why ADO.NET instead of entity framework

查看:81
本文介绍了为什么ADO.NET而不是实体框架的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的老年人建议我使用ado.net而不是实体框架。



我尝试了什么:



为什么ado.net而不是实体框架

My seniors are suggesting me for using ado.net instead of entity framework.

What I have tried:

Why ado.net instead of entity framework

推荐答案

这些是嵌套块。实体框架构建于ADO.NET之上。

ADO.NET处理您的应用程序和数据库之间的原始Sql连接和Sql查询。



实体框架是一个更高级别的框架。在内部,它使用ADO.NET创建和运行查询,但它提供了数据库的对象模型并支持LINQ(C#)查询。



虽然它更好使用并且不易出错,它有一些不足之处。主要表现。不是因为EF性能不好,而是因为:



1.使用C#编写非常低效的SQL查询非常容易。这是初级开发人员的常见问题。顺便说一句,对于每个查询,使用LinqPad进行一些调查很容易解决。

2.很容易无意中写出几行意外地进行了大量的数据库查询。使用适当的DatabaseContext配置轻松修复(我个人认为DB上下文的默认配置是无穷无尽的问题源)



我怀疑你的大四学生想要使用ADO。 NET有两个原因;

- 他们不了解实体框架,他们担心因为他们听说过性能问题

- 他们都很清楚,但他们是担心他们的团队使用EF井的能力
These are nested block. Entity Framework is build on top of ADO.NET.
ADO.NET handles raw Sql connection and Sql query between your app and a database.

Entity Framework is a much higher level framework. Internally it creates and run query with ADO.NET, but it present an object model of the database and support LINQ (C#) query.

while it is much nicer to use and less error prone it suffer from a few shortfalls. mostly performance. Not really because EF has bad performance, but because:

1. it is extremely easy to write very inefficient SQL query using C#. And it is a common issue with junior developers. BTW this is easy to fix with a bit of investigation with LinqPad, for each query.
2. it very easy to inadvertently write a few lines which unexpectedly make a lot of database query. Easy to fix with proper DatabaseContext configuration (I personally think the default configuration of DB context is a source of endless such problem)

I suspect your senior want to use ADO.NET for either of 2 reason;
- they don't understand Entity Framework and they are worry because they heard of performance issues
- they know both well, but they are worry about their team ability to work with EF well


这篇关于为什么ADO.NET而不是实体框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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