0

A legacy database project was built as SQL DataSets (80 DataTables with about 1000 Functions). Now we are modernizing the project to better technology. What concerns of choice to migrate to Linq2SQL or EF.

PS. We don't want to re-write the entire database queries. I found a tool that helps generate Linq query from SQL query. Is there something similar to convert to EF?

Adham Enaya
  • 780
  • 1
  • 11
  • 29
  • 1
    Linq2SQL is dead, EF Core is modern but it may be difficult to work with such list of functions and has a lot of limitations. Consider to check another option https://github.com/linq2db/linq2db – Svyatoslav Danyliv Mar 04 '21 at 10:43
  • @SvyatoslavDanyliv thanks. As for linq2db, is using Linq quires, I mean if I was able to convert SQL to Linq some integration tools, can integrate them with this linq2db framework? – Adham Enaya Mar 04 '21 at 11:09
  • 1
    You can convert SQL to LINQ only by hands, if i correctly get your question. This one also may help, but also you have to tune LINQ query by yourself. http://www.sqltolinq.com/ – Svyatoslav Danyliv Mar 04 '21 at 11:33
  • You can scaffold your database with functions via T4 template and start working with linq2db in minutes. – Svyatoslav Danyliv Mar 04 '21 at 11:35
  • @SvyatoslavDanyliv why bot to put your comments in an answer so I can accept it. it was very helpful for me. – Adham Enaya Mar 04 '21 at 12:57
  • @SvyatoslavDanyliv is a T4 template used for WebAPI autogenerate (controllers and views), correct? how can it help in my case? – Adham Enaya Mar 04 '21 at 13:10
  • T4 template only for generating model from database. – Svyatoslav Danyliv Mar 04 '21 at 13:13

1 Answers1

3

LINQ to SQL is obsolete technology.

EF Core is modern way but has a lot of limitations in LINQ. So probably you will create new 100 functions when EF fail to translate your query.

Also consider look at https://github.com/linq2db/linq2db (disclaimer: I'm one of the creators). You can scaffold any database via T4 template. Functions also will be imported.

Difference between EF Core and linq2db, that linq2db has no ChangeTracker but it uses LINQ for CRUD operations. And actually there are almost no limitations in creating fast and correct SQL.

For translating SQL to LINQ I know only one tool http://www.sqltolinq.com/ I've tried that many years ago and don't know current status.

Svyatoslav Danyliv
  • 21,911
  • 3
  • 16
  • 32
  • "So probably you will create new 100 functions when EF fail to translate your query." I know this answer is over a year old now, but even back then, is this hyperbole really fair? I have a pretty large suite of .NET enterprise apps running on EF Core and only needed a small handful (3-4) raw sql queries, the remaining 99% uses LINQ. Saying there's a lot of limitations using LINQ in EF Core seems to only hold in edge cases or poor designs, in my experience. – Luke Jul 25 '22 at 16:06
  • 1
    Yeah, depends on task. If you are creating reporting queries, probably you may fail or create less effective queries. EF Core become better from year to year, so probably 99% is good percentage for CRUD and not too complex database queries. – Svyatoslav Danyliv Jul 25 '22 at 16:24