Difference between linq to sql and entity framework?

For "production" releases, both EF & L2S require that a data model (read: Database schema) be in place before any classes can be generated. The ability to create your classes first and then generate the DB from that is available in the form of the EF4 CTP that ScottGu blogged about recently As far as a single Entity reflecting multiple tables: I believe that is currently a one-to-one relationship: 1 table = 1 Entity.

For "production" releases, both EF & L2S require that a data model (read: Database schema) be in place before any classes can be generated. The ability to create your classes first and then generate the DB from that is available in the form of the EF4 CTP that ScottGu blogged about recently. As far as a single Entity reflecting multiple tables: I believe that is currently a one-to-one relationship: 1 table = 1 Entity.

Thanks Allen, Yes EF4 can do it both ways. When starting a new project which one should be preferred? And why.

– Praneeth Aug 23 '10 at 16:53 According to Microsoft, when doing . NET 4.0, EF4 is the preferred solution for doing O/RM. Many new technologies will be placed on top of EF (WCF Data Services for instance) and while Microsoft still fixes bugs on L2S, it is not being developed anymore.

Or as they call it; it is done ;-) – Steven Aug 23 '10 at 18:32.

I believe with either EF 4, or an add-on, you can create your model first and have it generate your DB schema. Prior to EF 4, and with Linq-to-SQL you need to start with the DB and map the models.

– Praneeth Aug 23 '10 at 16:55 Not sure there is a "preferred approach. " If you already have a DB, I'd use the Linq tools to model it in code. If you're starting a completely new project and don't have the DB, then perhaps the code first approach would be better – taylonr Aug 23 '10 at 17:53 Indeed: The LINQ to SQL DataContext class contains a CreateDatabase method that allows you to build a database from a model.

L2S does not contain a feature to generate the SQL statements for this, as the EF4 designer has. However, when you use the Log property, you'll probably get pretty close. – Steven Aug 23 '10 at 18:35.

In linq to SQL you first make a database, then import it, build the app and your objects will be made. I started to fool around with EF at first learning MVC, then at the point of starting to work with the code I used linq to SQL, and, well, it's both linq, there is no real difference in the linq queries that I can tell.

There certainly are differences. Especially between L2S and EF3.5. EF3.5 for instance does not support Single and SingleOrDefault.It does not know how to translate queries that have a Contain method (for instance: from c in db. Customers where ids.

Contains(c.Id) select c). Besides this, the performance and readability of the L2S is much, much better. All of this was fixed BTW with EF4.

– Steven Aug 23 '10 at 18:38.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions