开发者

Do ORM frameworks take care of / suggest indices on the DB tables?

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.

  1. In mapping objects to relations, do these frameworks also suggest indices that may be necessary for the queries to execute efficiently?
  2. The queries generated by ORMs, are they efficient in the relational domain? Do they mostly work fine as generated, or is there intervention required?
  3. 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.

  1. Not in my experience. Use Query Analyzer or similar for that.
  2. 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.
  3. 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).
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜