使用哪个 ORM?

发布于 2024-08-30 01:34:22 字数 1246 浏览 5 评论 0原文

我正在开发一个包含这些类的应用程序:

class Shortcut
{
    public string Name { get; }
    public IList<Trigger> Triggers { get; }
    public IList<Action> Actions { get; }
}

class Trigger
{
    public string Name { get; }
}

class Action
{
    public string Name { get; }
}

我将有 20 多个类,它们将从 TriggerAction 派生,所以最后,我将有 1 个 Shortcut 类、15 个 Action 派生类和 5 个 Trigger 派生类。

我的问题是,哪种 ORM 最适合此应用程序? EFNHSubSonic 或其他内容(Linq2SQL)?

我将定期发布新的应用程序版本,添加更多触发器和操作(或更改当前触发器/操作),因此我也必须更新数据库架构。我不知道 EFNH 是否提供了任何好的方法来轻松更新架构。或者如果他们这样做,是否有任何教程如何做到这一点?

我已经找到这个 关于 NH 架构更新的文章,引用:

幸运的是NHibernate为我们提供了更新现有模式的可能性,即NHibernate创建了一个可以应用于数据库的更新脚本。

我从未找到如何实际生成更新脚本,因此我无法告诉 NH 更新架构。也许我误读了一些东西,我只是没有找到它。

注意:如果您建议EFEF 1.0也适合吗?我宁愿使用一些较旧的 .NET 而不是 4.0。
注2: ORM 框架应该免费用于商业用途。
注3:我还将使用代码混淆,随机重命名所有符号等......所以ORM应该支持这一点。

I'm developing an application which will have these classes:

class Shortcut
{
    public string Name { get; }
    public IList<Trigger> Triggers { get; }
    public IList<Action> Actions { get; }
}

class Trigger
{
    public string Name { get; }
}

class Action
{
    public string Name { get; }
}

And I will have 20+ more classes, which will derive from Trigger or Action, so in the end, I will have one Shortcut class, 15 Action-derived classes and 5 Trigger-derived classes.

My question is, which ORM will best suit this application? EF, NH, SubSonic, or maybe something else (Linq2SQL)?

I will be periodically releasing new application versions, adding more triggers and actions (or changing current triggers/actions), so I will have to update database schema as well. I don't know if EF or NH provides any good methods to easily update the schema. Or if they do, is there any tutorial how to do that?

I've already found this article about NH schema updating, quoting:

Fortunately NHibernate provides us the possibility to update an existing schema, that is NHibernate creates an update script which can the be applied to the database.

I've never found how to actually generate the update script, so I can't tell NH to update the schema. Maybe I've misread something, I just didn't found it.

Note: If you suggest EF, will be EF 1.0 suitable as well? I would rather use some older .NET than 4.0.
Note 2: The ORM framework should be free for commercial usage.
Note 3: I will also use code obfuscation, randomly renaming all symbols etc... so to ORM should support this.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

梦情居士 2024-09-06 01:34:22

在 .NET 4 之前,实体框架还不够成熟,不符合我的口味。此外,它不支持 POCO。

如果没有 EF,我会选择 NHibernate。为了使配置基于代码并且更容易一些,我还会使用 Fluent NHibernate。 NHibernate 非常成熟并且有很多社区支持。它具有从最新代码更新数据库模式的出色功能。强烈推荐。

我认为其他任何一个都不是认真的选择。实体框架将迅速获得人们的关注,因为它是内置的并且由微软认真推销。 NHibernate 仍将是一个可行的竞争对手,因为它非常受欢迎且成熟。其余的将慢慢被抛在一边,直到只有少数热心支持者使用。

Before .NET 4, Entity Framework was just not mature enough for my tastes. Furthermore, it does not support POCOs.

With EF out, I would select NHibernate. To make configuration code-based and somewhat easier, I would also use Fluent NHibernate. NHibernate is very mature and has lots of community support. It has an excellent facility for updating the database schema from the latest code. Highly recommended.

I don't think any of the others are serious options. Entity Framework is going to gain mind share rapidly because it is built-in and seriously marketed by MS. NHibernate will remain a viable competitor because it has plenty of popularity and maturity. The rest will slowly fall by the wayside until they are only used by small numbers of ardent supporters.

离线来电— 2024-09-06 01:34:22

我认为您在这里比较了两类不同的系统:

  • SubSonic 和 Linq-to-SQL 是数据库顶部相当简单的薄层。它们基本上只提供数据库表和域对象之间的 1:1 映射。如果这对您的情况足够好,那么这些工具是最简单、最容易使用且性能最好的 ORM。

  • .NET 4 中的 EF 和 NHibernate 属于完全不同的类别 - 它们提供企业级功能,它们支持多个数据库,它们支持将数据库结构映射和变形为不同的域结构,并且它们擅长于此。 EF4 也支持 POCO,并且之前针对 EF 使用的所有问题对于 .NET 4 版本的实体框架来说几乎没有任何意义。

    但是 NHibernate 和 EF4 都更复杂,它们需要更多的设置,更多的学习曲线,直到您“掌握它”,它们的脚步有点重,它们有额外的映射层来启用这些高级功能,但它们还具有成本效益,并且它们通常使事情变得更加复杂。

所以我想这实际上可以归结为您的要求:如果您需要一个相当简单且易于使用的系统,请选择 Linq-to-SQL 或 Subsonic。如果您需要更多企业级功能并且不介意设置这些 ORM 所需的额外工作,请选择 EF4 或 NHibernate。

I think you're comparing two separate classes of systems here:

  • SubSonic and Linq-to-SQL are fairly simple, thin layer on top of a database. They provide basically only a 1:1 mapping between a database table and a domain object. If that's good enough for your case, then these tools are the simplest, the easiest to use, and the best performing ORM's, too

  • EF in .NET 4 and NHibernate are in a quite different class - they provide enterprise-level features, they support multiple databases, they support mapping and morphing your database structure into a different looking domain structure, and they're good at that. EF4 does also support POCO and all the issues that have been used against EF before are pretty much moot with the .NET 4 version of Entity Framework.

    But both NHibernate and EF4 are more complex, they require more setup, more learning curve until you "get it", they're a bit heavier on their feet, they have additional mapping layers that enable those advanced features, but they also cost performance and they make things more complicated in general.

So I guess it really boils down to what your requirements are: if you need a fairly simple and easy to use system, go with Linq-to-SQL or Subsonic. If you need more enterprise-level features and don't mind the extra work needed to setup those ORM's, pick EF4 or NHibernate.

黑白记忆 2024-09-06 01:34:22

请参阅DataObjects.Net:虽然它是商业的,但有您需要的功能(例如架构升级)。

See DataObjects.Net: although it's commercial, there are features you need (e.g. schema upgrade).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文