<p>I'm currently working on putting together a fairly simple ORM tool to serve as a framework for various web projects for a client.  Most of the projects are internal and will not require massive amounts of concurrency and all will go against SQL Server.  I've suggested that they go with ORM tools like SubSonic, NHibernate, and a number of other open source projects out there, but for maintainability and flexibility reasons they want to create something custom.  So my question is this: What are some features that I should make sure to include in this ORM tool?  BTW, I'll be using MyGeneration to do the code generation templates.</p>

[{'answer_id': 50390, 'author': 'DevelopingChris', 'author_id': 1220, 'author_profile': 'https://Stackoverflow.com/users/1220', 'pm_score': 1, 'selected': False, 'text': "<p>You need to go the nHibernate style, in my experience, and have it so that you have some kind of map, between your objects and the database. This allows your objects to have some things that are hard to represent in a database but are easier represented in POCOs.</p>\n\n<p>Generation gets you started, by giving you classes that meet your schema, but if you plan on maintaining anything or testing anything, mapping is pain now for pleasure later.</p>\n\n<p>Subsonic is a great model, and its open source, if you must go generation, use their templates in myGeneration to get a leg up.</p>\n\n<p><strong>BTW: I've done what you are doing, and I ended up with something very similar to subsonic, and now advise my clients to take the subsonic source, and fork it for themselves.</strong></p>\n"}, {'answer_id': 50403, 'author': 'Jason Bunting', 'author_id': 1790, 'author_profile': 'https://Stackoverflow.com/users/1790', 'pm_score': 5, 'selected': False, 'text': "<p>For the love of all that's holy (and the women and the children), do everything possible to convince them not to go with a custom O/RM solution. Why are people wanting to re-invent the wheel when there are perfectly-good, open-source wheels already in existence?!?!</p>\n"}, {'answer_id': 166731, 'author': 'Mauricio Scheffer', 'author_id': 21239, 'author_profile': 'https://Stackoverflow.com/users/21239', 'pm_score': 2, 'selected': False, 'text': '<p>IMO writing your own OR/M is one the worst design decisions you could ever make. "maintainability and flexibility" are reasons exactly NOT to write your own OR/M.</p>\n\n<p>Please read <a href="http://ayende.com/Blog/archive/2006/05/12/25ReasonsNotToWriteYourOwnObjectRelationalMapper.aspx" rel="nofollow noreferrer">See 25 Reasons Not To Write Your Own Object Relational Mapper</a>, and see if your client really wants to pay what it costs to build something like <a href="http://www.ohloh.net/projects/nhibernate" rel="nofollow noreferrer">NHibernate</a> ($7.6M) or <a href="http://www.ohloh.net/projects/6727" rel="nofollow noreferrer">SubSonic</a> ($1.5M). Because, like ChanChan said above, you will end up with something similar to that.</p>\n'}, {'answer_id': 405222, 'author': 'Liviu', 'author_id': 378068, 'author_profile': 'https://Stackoverflow.com/users/378068', 'pm_score': 1, 'selected': False, 'text': '<p>Maybe just maybe, you need badly some "features" that do not exist yet in the existing solutions. Maybe you need something simpler also. 1.5$ for Subsonic is simply outrageous. \nMaybe  you want to use POCO. Maybe you want to use the stuff easily in a 3 tier scenario.\nMaybe you don\'t want to support ALL RDBMS on the planet, so you can hardcode and optimize the code just for your target. Maybe you want to implement smarter object tracking. Maybe some design decisions made by the existing orms drive you crazy....</p>\n\n<p>I myself am using a custom orm developed by me myself and i, and i am satisfied that i did it. There is no hidden dragon under the carpet, no surprise scenario. My orm does exacty what i want it to do, nothing less, nothing more.</p>\n'}, {'answer_id': 1424761, 'author': 'Dale', 'author_id': 173197, 'author_profile': 'https://Stackoverflow.com/users/173197', 'pm_score': 3, 'selected': False, 'text': '<p>If your client isn\'t interested in OSS because of (real or imagined) perceptions about support, have you considered any of the top-quality commercial third-party ORMs such as <strong><a href="http://www.mindscape.co.nz/products/LightSpeed" rel="nofollow noreferrer">LightSpeed</a></strong> that comes with a nice GUI designer tool</p>\n\n<p><a href="https://i.stack.imgur.com/A0l89.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/A0l89.jpg" alt="LightSpeed ORM"></a><br>\n<sub>(source: <a href="http://www.mindscape.co.nz/images/chrome/screendump.jpg" rel="nofollow noreferrer">mindscape.co.nz</a>)</sub>  </p>\n\n<p><a href="http://www.mindscape.co.nz/" rel="nofollow noreferrer">Mindscape</a> (the company that sells LightSpeed) is a New Zealand company based near where I live, I have met some of the devs there, and I know they are famous for having incredible customer support. And they give you the source code when you buy the software, so you can tweak it any way you like.</p>\n\n<p>You probably don\'t want to have to roll your own ORM unless you have to <strong>and</strong> your client is willing to hand over a stupid amount of cash for you to do so.</p>\n'}, {'answer_id': 1424778, 'author': 'Noon Silk', 'author_id': 154152, 'author_profile': 'https://Stackoverflow.com/users/154152', 'pm_score': 0, 'selected': False, 'text': '<p>No-one has mentioned it yet; but go with <a href="http://www.llblgen.com/" rel="nofollow noreferrer">LLBLGen</a>. You may customise the template as you like, and you may also, obviously, write your own custom code in the generated classes. Buy it. You will never look back, and you will be saying "Thank you silky!" when it consistently works beautifully. (I didn\'t write it, but I love it). If it doesn\'t work out for you, you may also say "Damn you silky!". But that\'s unlikely, however I do offer it as an option.</p>\n\n<p>The only bad thing I noticed about LLBLGen has been the support for switching between Databases/servers on the fly. It doesn\'t support a feature that I\'d like; namely the ability to detect that a given entity you retrieved doesn\'t "exist" in a new database that you\'ve switched to. But this is a rare case.</p>\n\n<p>I suggest LLBLGen, because I was in the process of writing my own OR/M when I came across it. Never looked back.</p>\n'}, {'answer_id': 1425113, 'author': 'Brendan Kowitz', 'author_id': 25767, 'author_profile': 'https://Stackoverflow.com/users/25767', 'pm_score': 2, 'selected': False, 'text': '<p>There\'s a bunch of posts by Davy Brion (an NHibernate committer) who is for some reason also forced to write a custom ORM for a client.</p>\n\n<p>Some of the things he covers are:</p>\n\n<ul>\n<li>Mapping Classes To Tables</li>\n<li>Out Of The Box CRUD Functionality</li>\n<li>Hydrating Entities</li>\n<li>Session Level Cache</li>\n<li>Executing Custom Queries</li>\n</ul>\n\n<p>Definately worth checking out, if you MUST go down this path: <a href="http://davybrion.com/blog/2009/08/build-your-own-data-access-layer-series/" rel="nofollow noreferrer">Build Your Own Data Access Layer Series</a></p>\n'}, {'answer_id': 1425132, 'author': 'Steven Evers', 'author_id': 48553, 'author_profile': 'https://Stackoverflow.com/users/48553', 'pm_score': 0, 'selected': False, 'text': "<p>Your job as a consultant (sounds like that's what you are) is to leverage your expertise in implementing for your clients a solution that fits their desires with a minimum cost and time investment.</p>\n\n<p>If they want to build and sell an OR/M. The go to town making one. If they want anything else, use one that already exists to get the job done.</p>\n\n<p>If they insist on spending money, buy an existing one (I won't name any, but there exist some good ones that are not free).</p>\n"}, {'answer_id': 1425160, 'author': 'Arthur Ronald', 'author_id': 127359, 'author_profile': 'https://Stackoverflow.com/users/127359', 'pm_score': 1, 'selected': False, 'text': '<ul>\n<li><p>Second level cache</p>\n\n<p>Allows you maintain entities instances in-memory</p>\n\n<ul>\n<li><p>Automatic dirty-checking</p>\n\n<p>Allows you updates changes in an object without loading it.</p></li>\n<li><p>Powerful query language</p></li>\n<li><p>Powerful cascade operation</p></li>\n<li><p>Powerful primary key generator strategy</p>\n\n<p>ORM framework will pickup best primary key generator strategy according to target database </p></li>\n<li><p>Support to composite elements</p></li>\n<li><p>Support to events</p>\n\n<p>onSave, onUpdate and so on</p></li>\n<li><p>Good documentation and reference books</p></li>\n<li><p>Support to conversational state</p></li>\n</ul></li>\n</ul>\n\n<p>regards,</p>\n'}, {'answer_id': 3961065, 'author': 'JackD', 'author_id': 360115, 'author_profile': 'https://Stackoverflow.com/users/360115', 'pm_score': 0, 'selected': False, 'text': '<p>Try to use <a href="http://www.devart.com/linqconnect/" rel="nofollow">Devart LinqConnect</a> - all of the LINQ to SQL features and wide support of the most popular database servers - Oracle, MySQL, Postgre, SQL Server, and SQLite. Incredible Visual Modeling tool, advanced monitoring tool, high quality support - as a result i\'ve learned it only in three weeks during my project execution.</p>\n'}]
['https://Stackoverflow.com/questions/50386', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/4541/']