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 开发者_JAVA百科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.
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.
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.
See DataObjects.Net: although it's commercial, there are features you need (e.g. schema upgrade).
精彩评论