6

To get the prototype for a project up and running as quickly as possible, I used LINQ to SQL for data persistence.

Now the project is more mature and I'm running into concurrency limitations with LINQ to SQL. Since its not a true ORM, nor was it meant for enterprise use, I'd like to replace all the LINQ to SQL work with Entity Framework persistence.

What's involved in this? Can any of my LINQ to SQL work be retooled for EF? Am I going to have to start over with EF from scratch? Where do I start? Any helpful links or advice?

4
  • 4
    "Since its not a true ORM, nor was it meant for enterprise use" - Stackoverflow is built using L2S - I'd say that's enterprise ready! Commented Jan 25, 2011 at 20:00
  • 1
    Like @geoff said, SO is built on L2S, so it's definitely able to be used in the enterprise. What might be of interest is what the concurrency limitations you are running into; there might be a perspective offered here which can help you address those without having to move to another ORM wholesale. Commented Jan 25, 2011 at 20:03
  • Ok.stackoverflow is built using linq to sql and you can use this for enterprise project. Commented Jan 25, 2011 at 20:08
  • I would trya nd make sure that your "Concurrency Limitations" maybe due to db design rather than Linq2Sql Commented Jan 26, 2011 at 11:34

3 Answers 3

3

Many people are doing the same conversion. There is a template that you can use to do the conversion here http://blogs.msdn.com/b/efdesign/archive/2009/08/13/linq-to-sql-to-entity-framework-conversion-template.aspx

Sign up to request clarification or add additional context in comments.

2 Comments

It isn't clear how "many" people are doing this conversion. If you scroll down in the comments, you will find this "While there has been some interest, so far the interest has not been enough to justify further investment in this project... "
Is there any updated version of that template? It is 3 years old so I have doubts about using it.
1

This is a fairly hard problem and one of the main reasons I have been recommending people avoid LinqToSql for quite a while. Microsoft does not want people using LinqToSql.

Your best bet is likely to start over and reuse code when/if you can (some of your Linq queries may translate almost one for one automatically, but even that isn't a sure thing).

LinqToSql is a true, but feature poor, ORM. LinqToSql can and is used in the enterprise by people who don't require advanced ORM features.

You aren't likely the only person who will go down this path (trying to "upgrade" from LinqToSql to EntityFramework), but it's not clear at this point if there is a market need for good tooling to support this kind of migration.

Given Microsoft's direction changing on data access every two years or so for more than a decade now, you may want to consider NHibernate as an alternative to Entity Framework (if you are worried about Microsoft "sunsetting" Entity Framework like they did to LinqToSql).

Comments

0

I doubt that some kind of automatic conversion is possible. There are few differences. The worst on is the way of calling Stored Procedures with scalar return values. EntityFramework does not return the value, but number of rows affected. This requires changes in your T-SQL. This cannot be done by any template. Some LINQ2SQL queries does not work in EntityFramework and need to be changed. There is annoying difference in pluralization. EF try to be so clever. Table UserInfo is pluralize as UserInfoes while L2SQL UserInfos. Table Persons is pluralized as Poeple instead of Persons. So you need to changes these pluralization as well. If you use some advance work with connections (don't use connection string), you can just upgrade it. DBConnection is not compatible with EntityConnection. You need to rewrite this layer of your app as well. Lots of hard job for conversion template.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.