If I am using SQL Server as my dat开发者_开发百科abase service, is there any compelling reason to look at LINQ to Entities over Linq to SQL?
Linq to SQL is no longer being actively developed - they are focusing their resources on Entity Framework. Also, EF is far more robust and allows for a number of more advanced scenarios that were overlooked in Linq to Sql.
While you are investigating ORMs, I would take a serious look at NHibernate. It has been around longer than either of Microsoft's offerings and is far more versatile.
Linq to SQL is good enough if you only want a one-to-one mapping between your classes and tables, think of it as a “object” version of datasets.
EF lets you do a lot more complex mappings.
In the long term Microsoft is pushing everyone towards EF, however EF is more complex to use. Until .net 4 ships it is very hard to do test drive development with EF.
If you are going to hide all the data access behind a set of interfaces and create the domain objects yourself based on the rows you get from the database, then Linq to SQL is a good option in the short term. But you may be forced to move to EF in the long term.
If you wish to map your domain objects to your database using an ORM, then EF is a better object, however also also consider nhibernate
If you come back in a few years time the answer to your question would be EF, however it is not clear cut at present…
There are so many compelling reasons to choose Entity Framework over LinqToSql, but you should need only one:
Microsoft would much rather you use Entity Framework. Microsoft is putting a large majority of their ORM development resources behind EF. That is their future road.
Unfortunately, EF 3.5 was a significant step back from LinqToSql in multiple ways so Microsoft really pushed a lot of people who wanted to use EF back to LinqToSql. With EF 4.0, EF is not completely feature equivalent to LinqToSql, but it's much closer.
EF 4.0 does offer many, many features that LinqToSql does not currently support and likely never will.
Stay away from EF 3.5 though. If you want an ORM for .NET 3.5, use NHibernate. For .NET 4.0, choose between NHibernate and Entity Framework. There is not really a good reason to use LinqToSql with .NET 4.0.
精彩评论