DEV Community

Cover image for How YOU can use an ORM in .NET Core and C# to type less SQL -starring Entity Framework

How YOU can use an ORM in .NET Core and C# to type less SQL -starring Entity Framework

Chris Noring on August 01, 2019

We all love SQL right? No? Well sometimes a good SQL query is the best approach but most of the time it's the same CRUD operations that you need t...
Collapse
 
stsrki profile image
Mladen Macanović

Good article but how you started about diferent ORMs I was hoping you will try to mention some other than the Entity Framework like everyone else is doing. Maybe like github.com/linq2db/linq2db which is in some ways miles better than EF.

Collapse
 
softchris profile image
Chris Noring • Edited

Hi Mladen. Did not know about that one. Will have a look, thanks :) I've added a list of links to other ORMs. I will need to make a separate article for it though

Collapse
 
stsrki profile image
Mladen Macanović

It would be great if you could make a separate article about Linq2DB as they desperately need some marketing. I use it in the production for years and just love it! If you need help just let me know.

Thread Thread
 
lewiscowles1986 profile image
Lewis Cowles

Why aren't you authoring an article instead of asking others to do so?

Thread Thread
 
stsrki profile image
Mladen Macanović

I would like to,but since I'm a terrible writer it would be just a huge pile of you know what..

Collapse
 
evgenykhaliper profile image
Evgeny Khaliper

Totally disagree with statement "ORM is knowing what goes to the dababase" this is exactly the reason why many avoid using ORMs because you have zero visibility when you save objects in c# and ORM does its magic on how and when to save actual data.

Collapse
 
softchris profile image
Chris Noring

maybe I didn't explain this well enough. I come from a background where no one knew what lived in a database. Things like functions, triggers, and other things had just been added over time. The way I see it, using an ORM is about defining your database in code and thereby you can have it under version control, at least the structure. I agree that ORMs are tricky. I have been struggling myself over the years with concepts such as tracking and having to write custom SQL cause what the ORM generated was just slow. I guess the alternative is stored procedures. The way I see it there are no silver bullets, just different types of problems. The speed you get initially becomes complexity later on.

Collapse
 
nssimeonov profile image
Templar++

The more I read, the more convinced I am, that a friend's joke about EF is totally true: People use EF, because they don't want to learn SQL and are afraid to use it.

Thread Thread
 
softchris profile image
Chris Noring

As I wrote in my article. It's important to know what SQL EF generates and for reporting queries, for example, you need to write your own SQL. It's important to know when to use a tool and when to rely on SQL. An ORM is NOT a replacement for SQL, it just abstracts away basic SQL.

Collapse
 
viliamjr profile image
Viliam • Edited

Great tutorial!

Additionaly, it was necessary:

1) to create a solution: 'dotnet new sln'
2) to install EF tool: 'dotnet tool install --global dotnet-ef'