.NET: Converting from LINQ to SQL in Entity Framework

To get the prototype to start and run the project as quickly as possible, I used LINQ to SQL to save the data.

The project is now more mature, and I ran into concurrency limitations with LINQ to SQL. Since it is not a true ORM and is not intended for enterprise use, I would like to replace all LINQ work with SQL persistence based on Entity Framework.

What is involved in this? Is it possible to redirect any of my LINQ to SQL to EF? Should I start with EF from scratch? Where to begin? Any useful links or tips?

+6
database orm linq-to-sql entity-framework
source share
3 answers

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

+3
source share

This is a rather complex problem, and one of the main reasons I have recommended people to avoid LinqToSql for a while. Microsoft does not want people to use LinqToSql.

Your best bet is likely to start over and code reuse when you can (some of your Linq queries can automatically translate almost one on one, but even this is not necessary).

LinqToSql is a true but bad result, ORM. LinqToSql can and is used in the enterprise by people who do not require advanced ORM features.

You are unlikely to be the only person who will go this route (trying to β€œupgrade” from LinqToSql to EntityFramework), but at this stage it is not clear whether there is a market need for good equipment to support this kind of migration.

Given that Microsoft has been pushing changes in data access every two years or so for more than ten years, you might need to consider NHibernate as an alternative to the Entity Framework (if you worry about Microsoft rolling up the Entity Framework, as it were done with LinqToSql).

+1
source share

I doubt automatic conversion is possible. There are several differences. Worst of all, calling stored procedures with scalar return values. EntityFramework does not return a value, but the number of rows affected. This requires a change in your T-SQL. This cannot be done with any template. Some LINQ2SQL queries do not work in EntityFramework and need to be changed. There is an annoying difference in pluralization. EF try to be so smart. The UserInfo table is pluralize as UserInfoes during L2SQL UserInfos. Table Faces are pluralized as Poeple instead of humans. Therefore, you also need to change this pluralization. If you use some preliminary work with connections (do not use the connection string), you can simply update it. DBConnection is not compatible with EntityConnection. You must also rewrite this layer of your application. A lot of hard work for the conversion template.

0
source share

All Articles