Why We Recommend EF Core over XPO for New Development(为什么我们推荐在新开发中使用 EF Core 而不是 XPO)
XAF supports two Object-Relational Mapping tools: Entity Framework Core and DevExpress XPO. As you might expect, we often receive comparison requests from XAF UI and Web API Service users: which ORM should I choose? The answer, of course, depends on your tasks, and on how familiar you are with XPO and EF Core. Review the information in this topic to choose the ORM that suits your business needs best in the following scenarios:
XAF支持两种对象关系映射工具:Entity Framework Core和DevExpress XPO。正如您所料,我们经常收到来自XAF UI和Web API Service用户的比较请求:我应该选择哪种ORM?答案当然取决于您的任务,以及您对XPO和EF Core的熟悉程度。查看本主题中的信息,以在以下场景中选择最适合您业务需求的ORM:
- You are new to our application frameworks, have no knowledge of either ORM, and do not yet know which one to choose.
您是我们应用程序框架的新手,对任一ORM都不了解,并且还不知道该选择哪一个。 - You are starting a new project, have experience with XPO or EF Core, and want to re-evaluate your choice due to ORM issues or new opportunities.
您正在开始一个新项目,有使用XPO或EF Core的经验,并且由于ORM问题或新机会而希望重新评估您的选择。
EF Core is the default choice in the Solution Wizard and Getting Started tutorials in v23.1 and later. This change was made because we consider EF Core to be the best choice for new XAF and Web API Service development.
EF Core是v23.1及更高版本的解决方案向导和入门教程中的默认选择。之所以进行此更改,是因为我们认为EF Core是新XAF和Web API Service开发的最佳选择。
Should Existing XPO Users Migrate to EF Core?(现有XPO用户应该迁移到EF Core吗?)
If you have experience with both ORMs and prefer XPO to EF Core, you can continue to use XPO even for new projects - there is no need to switch to EF Core.
如果您有两种ORM的经验并且更喜欢XPO而不是EF Core,那么即使对于新项目,您也可以继续使用XPO-无需切换到EF Core。
Reasons not to switch to EF Core include:
不切换到EF Core的原因包括:
- We are proud of XPO and all that it offers; it is a mature ORM that we still use in several of our internal projects along with EF Core. New and existing DevExpress customers also continue to use XPO.
我们为XPO及其提供的一切感到自豪;它是一个成熟的ORM,我们仍然在几个内部项目中与EF Core一起使用。新的和现有的DevExpress客户也继续使用XPO。 - We continue to develop new XAF and Web API Service features that meet user needs and market demand for XPO and EF Core (there is no “EF Core-First” policy for new XAF development). For instance, XPO supports .NET Core 3, 5, 6, 7, 8, and is expected to support .NET vNext in the future. The new XAF Web API Service and Multi-Tenancy module also support XPO.
我们继续开发新的XAF和Web API Service功能,以满足用户需求和市场对XPO和EF Core的需求(新XAF开发没有“EF Core-First”政策)。例如,XPO支持。NET Core 3、5、6、7、8,并有望在未来支持。NET vNext。新的XAF Web API Service和Multi-Tenancy模块也支持XPO。 - We will continue to fix security and other XPO bugs (see Version History), enhance XPO code, and update learning materials for XPO users.
我们将继续修复安全性和其他XPO错误(请参阅版本历史)、增强XPO代码并更新XPO用户的学习材料。
When choosing an ORM, we advise that you evaluate the current ORM state as it relates to the issues and requirements of your projects.
在选择ORM时,我们建议您评估当前的ORM状态,因为它与您的项目的问题和要求相关。
Compatibility Considerations on a Potential Migration from XPO to EF Core(关于从XPO到EF Core的潜在迁移的兼容性考虑)
To reiterate, DevExpress is not requiring nor asking our customers to migrate from XPO to EF Core. Migration considerations for new projects should be based on your strategic investment in .NET, its potential market changes and the growing popularity of EF Core (see below).
重申一下,DevExpress不要求也不要求我们的客户从XPO迁移到EF Core。新项目的迁移考虑应该基于您对. NET的战略投资、其潜在的市场变化和EF Core的日益普及(见下文)。
Note that XPO and EF Core are entirely different ORMs. These tools handle many things differently; for instance, inheritance and database schemas for the same logically equal entities will be different for these ORMs with default settings. Business classes for these ORMs cannot be used with the same database tables. We did not plan to make these classes compatible (key type, table names, etc.). Applications cannot easily be moved from XAF to another ORM because of different table structures in their data models. Technically, it is possible to migrate your XAF code from one ORM to another (and we have had a few such customers), but you will also need to manually modify your table structure and migrate data (this requires a deep understanding of ORM internals and we do not consult on such matters).
请注意,XPO和EF Core是完全不同的ORM。这些工具处理许多事情的方式不同;例如,对于这些具有默认设置的ORM,相同逻辑上相等的实体的继承和数据库模式将是不同的。这些ORM的业务类不能与相同的数据库表一起使用。我们没有计划使这些类兼容(键类型、表名等)。由于其数据模型中的表结构不同,应用程序无法轻松地从XAF移动到另一个ORM。从技术上讲,可以将您的XAF代码从一个ORM迁移到另一个ORM(我们已经有一些这样的客户),但您还需要手动修改表结构并迁移数据(这需要对ORM内部进行深入了解,我们不会就此类事项进行咨询)。
XPO vs EF Core: Similarities(XPO与EF Core:相似之处)
XPO vs EF Core: Differences(XPO与EF Core:差异)
Footnotes(脚注)
1.EF Core supports Middle Tier Security in v23.1 and later.
EF Core在v23.1及更高版本中支持中间层安全性。
2.All statistics are as of March 2023.
所有统计数据截至2023年3月。