Linq-to-SQL or Linq-to-Entities with ASP.NET 3.5 and SQL Server 2005
I am starting a new project using C# and A开发者_如何学GoSP.NET 3.5 with SQL Server 2005, and I am trying to decide which ORM is the best to use between LinqToSQL, LinqToEntities, or NHibernate.
Ideally I would like to use the preferred Microsoft best practice; but I need to use a solution that will provide performance comparable to using stored procedures without the maintenance overhead, and be easy to deploy updates to the web application and the database since we are in an Enterprise environment and the database is controlled by another group.
I really like the ease of use that LinqToSQL provides, and I am leaning towards any Linq solution over NHibernate.
Thanks in advance for all recommendations!
Jason
If you're looking for the "preferred Microsoft best practice" then you want to go with the Entity Framework (Linq-to-Entites). Microsoft has said this is where they are focusing their efforts as regards ORM's. LINQ to SQL (I dont think) is being actively developed, other than maintenance and security fixes.
My personal opinion is to go with LINQ to SQL with smaller, simpler projects. The larger more robust applications I prefer to use EF.
NHibernate is also a very good solution, and it does have LINQ providers, so you might want to investigate that too (if for no other reason than just to be well informed). But for me, I need to stick to 'official' Microsoft solutions.
I think that Entity Framework is the MS recommended solution. NHibernate has a learning curve that you would need to get past, but probably the most feature rich ORM for .NET. EF however is just easy, drag your DB objects over and boom, you have the data access classes to work with!
I have tried all 3 ORM NHibernate, LINQ to SQL and Entity Framework 4. I blogged about my experiences on my blog at http://nileshgule.blogspot.com/2010/09/entity-framework-learning-series.html.
I think NHibernate has many advanced features but it suffers many time from a typical open source problem. It lacks good documentation and making simple things work for you might take few days. LINQ to SQL was Microsofts first forey into ORM world. Going forward its quite obivious that they are going to deprecate the SQL server specific LINQ to SQL technology. Hence choosing Entity Framework 4 would be a good option. I have summarized some of the differences between LINQ to SQL and Entity Framework 4 in my blog http://nileshgule.blogspot.com/2010/09/entity-framework-part-2-comparison.html
You can also refer to a very good video series by Julie Larman which are available at http://msdn.microsoft.com/en-us/data/ff191186.aspx
精彩评论