4

I know the high-level differences between linq to sql and entity framework, however, I am hoping for advice from someone else who has already made the switch themselves, or has sufficient experience with both. Coming from a strong linq to sql background, as far as implementation and low-level details, are there any important things I need to know as I start coding my new data access layer project with entity framework?

I already created my edmx file (I chose the database-first approach), and everything just seems suspiciously identical to linq to sql so far. What would help me is a short list of items, like, in linq to sql, you do [this] [this way], but in entity framework, you'll want to do it [this way].

Sorry if this is a strange question, but any attempts at answers would be greatly appreciated. Thanks!

StronglyTyped
  • 2,134
  • 5
  • 28
  • 48
  • while NH is more mature and has a richer set of features just saying "use NH" doesn't help the OP. – Jason Meckley Dec 22 '11 at 14:08
  • 2
    Possible duplicate of this: http://stackoverflow.com/questions/8676/entity-framework-vs-linq-to-sql – Strillo Dec 22 '11 at 14:09
  • I don't think there's anything fundamentally different in EF4 - you can pretty much go about doing your thing as you did in Linq-to-SQL. EF4 will offer *additional features* (like table inheritance scenarios, mapping one object to multiple tables or one table to multiple object types) - but those are "add-on" that don't really get in your way. – marc_s Dec 22 '11 at 14:49

2 Answers2

1

In new project between L2S and EF I suggest EF (consider Entity Framework version 4.0 or superior, DON'T use early EF releases).

While Linq to SQL is a class to table mapping EF 4 is a complete ORM (Object Relational Mapping) tool with different mapping scenarios.

With EF you have a lot of flexibility:

  • Database First approach
  • Model First approach
  • Code First approach

and a strong integration with LINQ Provider.

Unit testing with Linq2SQL is a nightmare. With EF you have POCO (Plain Old CLR Object) classes out of the box. In L2S the entity class is tight coupled to the L2S namespace.

EF can help you also in Domain Driven Design scenarios.

Microsoft consider now EF the first database access method and it's the base for other services like RIA services or MVC database scaffolding.

LinqToSql is now the first database access methodology only in Windows Phone scenarios.

Be.St.
  • 4,101
  • 3
  • 25
  • 35
  • What do you mean by "the first database access method"? Obviously neither of these technologies came first. – M.Babcock Dec 22 '11 at 18:43
  • Sorry for my poor english... I mean that in the database access technologies set (ADO.NET, LinqToSql, EF) EF is the preferred one for Microsoft and his effort is focused on it. – Be.St. Dec 23 '11 at 09:15
0

NH is far better... but again as EF is microsoft baby, it will grow as time goe

Constant Learner
  • 525
  • 4
  • 13
  • 30