Search code examples
asp.net-mvcormtddtestdrivendesign

TDD and MVC Crossroads. What ORM integrates nicely?


I'm just starting out in MVC world, and I've used a standard MVC template that's built into VS 2010. I've got a couple of controllers and views hooked up, and now I need to get to my database.

I've got an existing SQL Server 2005 database that is quite large, already defined by a 3rd party company. I'm trying to bolt on a reporting/admin interface to it for our specific company needs.

So, I'd like, initially to just pull a list of things out of a few tables from this DB. So...using MVC 3, what are some ORM tools that integrate nicely?

I'm also trying to use a Test Drive Design approach. I'm not sure what to do for tests that would require insert/update/delete of data. Is that were "Mocks" come into play?


Solution

  • Every ORM integrates nicely with Asp.net MVC. There is nothing in asp.net mvc that would make ORM integration hard.

    Your biggest hurdle is using a legacy database. NHibernate and Entity Framework 4 are the only two free ORMs I'm aware of that map to legacy databases well. EF4 isn't too bad at mapping to legacy databases it just works better with green field development. In contrast NHibernate can map almost any scenario you can think of.

    Testing ease is going to be mostly dependent on which data access pattern to use. The Repository pattern is popular because of how friendly it is to test with. No mocking is required.