views:

58

answers:

3

A good thing in LINQ to SQL was a fast and reliable way to map database tables and convert them into classes accessible from c# project. However it is no longer recommended to create projects using LINQ to SQL.

What is its substitute? What kind of tool should I use in VS 2010 today if I want to have the same functionality as I had with LINQ to SQL?

+7  A: 

Why not??

Linq-to-SQL is still around in .NET 4, even with bugfixes and improvements. For small projects, it's still a very viable solution!

Yes, there won't be much further development on it - but it's still there, it still works, and for many projects, it's a perfect fit - just use it!

If you want to have something "future-proof", you'll need to look at Entity Framework v4.

See this blog post with a ton of links on EF4.

EF4 looks very promising - but remember: it's always a two-stage mapping process (while Linq-to-SQL is a straight 1:1 mapping from table to object). This might be great if you need the flexibility, but it might be a drawback since it adds a certain overhead.

If you really don't want to keep using Linq-to-SQL, you might also want to check out SubSonic which is another simple, easy-to-use, straightforward 1:1 OR-mapper

marc_s
Thanks. What is in your opinion small project? When you say "small project", do you look at the number of code lines in the project (number of classes, subprojects, etc.)) or at the number of people who will use your application?
trnTash
@trnTash: mostly small in terms of how many tables do you have, how much functionality? Is it something a single dev or a team of two can easily manage? If so -> small project. If you need a staff of 5 or more, it's no longer a small project for me.
marc_s
A: 

I would try out Nhibernate. I think it works great, never used EF4 so can't really compare. Nhibernate makes you manually declare all mappings, but they are super easy and quick to bust out and doesn't have some of the limitations of using LINQtoSQL generated classes. Also depends on your preference but I like having full control of the classes I generate and interfaces I implement off them. Syntax might take some time to get used to but I think it is really powerful tool.

http://nhforge.org/

Also some amazing video tutorials of how to use it can be found right here: http://www.summerofnhibernate.com/

sah302
A: 

What you may have heard is that Microsoft will be spending its development efforts on Entity Framework instead of LINQ to SQL. Entity Framework is what you should look at as a LINQ to SQL replacement.

Although EF does not require a one-to-one mapping to the database, that is the default when you generate a new EF model from the database. In that way, it will be equivalent to LINQ to SQL.

John Saunders