Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which ORM supports mapping existing databases?

So I have a layered ASP.NET MVC proof-of-concept application with good separation between presentation concerns, business logic, and infrastructure concerns. Right now it is operating off of a fake repository (i.e. LINQ queries against static IQueryable objects). I would like to create a functional SQL repository now.

That said, I don't want to simply tie it into a database that has a 1-1 mapping between tables and entities. That wouldn't meet the business need I am hoping to solve (partial integration with existing database - no hope for convention over configuration).

Do you have suggestions for which ORM / mapping tools I should consider and/or avoid?
Do you have suggestions for articles/books I could look at to help me approach this topic?

Would it be better to simply use parameterized queries in this scenario?


2 Answers

Entity Framework in version 4 would definitely allow you to:

  • have a mapping between the physical database schema and your conceptual schema, e.g. having an entity mapped to several tables, or several tables joined together forming a single business entity

  • grab data from views (instead of tables directly)

  • use stored procedures (where needed and appropriate) for INSERT, UPDATE, DELETE on every entity

like image 156
marc_s Avatar answered Sep 05 '26 17:09

marc_s


NHibernate sounds like a good fit for what you are looking for. You will be able to make your repositories call queries in either HQL or using the API, either way you can get to your database and shape the data to fit the way your repository is being used. It will always be hard to make a square peg fit into a round hole though. SO has lots of nice support when you get into using NHibernate, good luck.

like image 24
Mark Dickinson Avatar answered Sep 05 '26 18:09

Mark Dickinson