views:

163

answers:

6

Hi guys

I am about to start a new project and am deciding what data access technology I will be using... I really like LINQ to SQL for a variety of reasons but should I start the new project using the Entity Framework instead??

I have this perception that the Entity Framework is more bloated and needlessly complicated, thus accounting for part of the reason I was thinking about going with LINQ to SQL... but as I said this may only be perception on my side as I haven't used the Entity Framework all that much.

So which would people recommend I use for starting a new project today (note this app will be around for years to come)?

Cheers Anthony

EDIT: We are SQL Server shop so we don't need database vendor independent.

Also is the generally agreed best way to abstract data access atm by using the Repository pattern which works with my domain objects?

+3  A: 

LINQ to SQL is about rapid development and simplicity. If your data model is complex, or might become so, you will be better off using a more robust framework.

That said, more important than your data access tool is how well you abstract it from the rest of your code. Done right, you should be able to start with LINQ to SQL and switch when you outgrow it (or when EF 2 4 comes out).

dahlbyk
+1  A: 

Linq to SQL works best in an active record / one table per class paradigm. If you need to span your class across several tables, or support complex inheritence then it may not be the best choice. Also, Linq to SQL doesn't natively support many-to-many relationships (there are workarounds).

If neither of those sound like they'd affect you, then Linq 2 SQL may be a good choice. It's a great lightweight data access strategy.

Linq to SQL can be used to implement the repository pattern very well given the above constraints. Google will turn up several viable Linq repository examples.

Daniel Auger
+2  A: 

Note that EF 1 is far from complete. It lacks all kinds of features you do find in LINQ to SQL, one of the more important ones being actual foreign key properties (can you imagine these don't exist in EF 1?)

Also, EF 4 will pretty much have all features of LINQ TO SQL, and both will generate relatively comparable (code wise) external API, so unless you're coding to very LINQ to SQL specific API's, it should be relatively easy to migrate to EF4 later on, 'simply' by replacing the LINQ to SQL .dbml with EF4's equivalent.

Ruben
There are some additional complexities around the update/insert syntax , change tracking and concurrency conflict resolution that shouldn't be dismissed.
DamienG
Granted, but if you encapsulate those parts, and chiefly use LINQ, the transition should not cause too many headaches.
Ruben
A: 

Have you taken a look at Subsonic - now in version 3 it is basically a linq to sql DAL that makes it possible to have full linq to sql of your entire database in under 5 mins. And it runs off T4 templates, so if you want to add to the templates it is REALLY EASY

http://www.subsonicproject.com/

Doug
A: 

I wrote up a pretty lengthy blog post on choosing a .NET ORM:

.NET and ORM - Decisions, decisions

Basically, NHibernate is your best bet. If you insist on something with simplicity like LinqToSql, consider SubSonic. I would not recommend either of the Microsoft options: LinqToSql or EntityFramework.

Deciding whether to use the repository pattern or not is situational depending on your requirements.

Michael Maddox
I recall NHibernate LINQ support being fairly limited in kinds of queries it can handle (i.e. it was fairly easy to write a less than trivial query and have it fail to process it), and generally labeled "experimental" by the authors. Has this changed?
Pavel Minaev
I could speculate on various ORMs support level for Linq, but I haven't seen anything real as far as data in that regard. This discussion should be a based on real data and as far as I know, that data doesn't exist. It seems like it would take a pretty significant amount of effort to gather that data.
Michael Maddox
A: 

Check out: http://www.icemanind.com/Layergen.aspx

icemanind