关于更换企业库数据访问块由实体框架的建议企业库、实体、框架、建议

2023-09-03 13:02:58 作者:敢抽我就阉了你i

数年前,我们开发了一个大型ASP.Net应用程序(C#/。NET 3.5),其必须是数据库引擎非依赖(这意味着该应用程序既可以使用SQL Server,Oracle,MySQL等...为DB引擎)。为此,我们使用企业库数据访问块4.1。

A few year ago, we developed a large ASP.Net application (C# / .net 3.5) that had to be "Database Engine" non-dependent (meaning this application could either use SQL Server, Oracle, MySQL ... as DB engine). For that, we used Enterprise Library Data Access Block 4.1.

但现在,因为我们是在性能/可扩展性改善的阶段,我们正在考虑技术升级或重新设计我们的应用程序的基础。

But now, as we are on a "performance/scalability improvement" phase, we are thinking about technology upgrade or re-design of our application foundations.

所以,问题是:是否有移动到实体框架的任何优势? EF是否将继续我们的非依赖型数据库引擎的标准?或者我们应该保持我们的EntLib DAAB实现,但升级到最新版本(5.0)?

So, the question is: is there any advantage to move to Entity Framework ? Does EF will keep our non-dependent "Database Engine" criteria ? Or should we keep our EntLib DAAB implementation but upgrade to the latest version (5.0) ?

感谢

推荐答案

它们之间移动最大的问题不是关于数据库的独立性,它的使用模式是根本不同的。数据访问块(DAAB)主要是围绕ADO.NET一个方便的包装。这使得它更容易/调用存储过程更讨人喜欢,但你仍然在处理数据集或数据读取器。它实际上并没有改变你如何与数据库交互,它只是使得它不太烦人。

The biggest issue moving between them isn't about database independence, it's that the usage pattern is fundamentally different. The Data Access Block (DAAB) is primarily a convenience wrapper around ADO.NET. It makes it easier / less annoying to call stored procedures, but you're still dealing with datasets or data readers. It doesn't actually change how you're interacting with the database, it just makes it less annoying.

实体框架,在另一方面,是关于数据建模和对象关系映射。它工作在更高层次上比DAAB做;你写你的code。在你的对象方面,而不是在数据集或的DataReader方面。它会自动从数据库中的对象的物化,所以你不需要编写code,保持它们之间的关系等,这是一个更全功能的,但完全不同,方式与工作数据库。

Entity Framework, on the other hand, is about data modelling and object-relational mapping. It works at a higher level than the DAAB does; you write your code in terms of your objects, not in terms of DataSets or DataReaders. It automates the "materialization" of the objects from the database so you don't need to write that code, maintains the relationships between them, etc. It's a much more fully featured, but quite different, way of working with the database.

您需要的,如果你要移动到数据访问的ORM风格首先要考虑的问题。从那里,你可以决定是否EF或.NET空间中的许多其他奥姆斯之一,将满足您的需求最好的。

You need to consider if you're going to move to the ORM style of data access first. From there you can decide if EF or one of the many other ORMs in the .NET space will suit your needs best.

有很多可供EF提供商(见列表Devart的答案),但他们是所有外部/额外费用。唯一一个在包装盒是SQL Server。虽然我会补充说,DAAB实际上并没有完全覆盖的数据库独立的东西 - 如果你有你的DAAB调用任何实际的SQL,它不会帮你的SQL方言的差异。 EF意志。

There are lots of providers available for EF (see Devart's answer for a list) but they're all external / extra cost. The only one in the box is for Sql Server. Although I will add that DAAB doesn't actually completely cover the "database independence" thing - if you have any actual SQL in your DAAB calls, it doesn't help you with differences in SQL dialects. EF will.