I haven't gotten into ORM frameworks much yet, and could use some input from experienced practitioners. Some of these questions may be naive. Please bear with me.
- In mapping objects to relations, do these frameworks also suggest indices that may be necessary for the queries to execute efficiently?
- The queries generated by ORMs, are they efficient in the relational domain? Do they mostly work fine as generated, or is there intervention required?
- What is the current consensus on the ORM of choice in the .NET w开发者_JS百科orld?
I have experience with Entity Spaces, a little with Entity Framework, and also some with NHibernate.
- Not in my experience. Use Query Analyzer or similar for that.
- Generally yes, but beware of the N+1 problem. Entity Framework allows you to pull back entities "with" child entities. NHibernate tries to be smart about it. You do have to keep an eye on what SQL is being generated, particularly for costlier queries.
- The TDD crowd favors NHibernate because it allows you to use POCO entities (and they tend to prefer the Unit of Work over the Active Record pattern for testability). On the other hand, Entity Framework comes with Visual Studio. Then again, there's always Linq to SQL (much lighter weight).
精彩评论