❔ Is Entity Framework still worth using
It has been a good 10 years or so since I used EF. From what I recall, it was good for code first and also for generating client side code directly from stored procedure outputs. Aside from that, there seemed to be few upsides for what seemed to be a fairly heavyweight ORM. I guess a lot has changed since those early days, and I understand EF is even a part of the .NET Core offering. Has anybody got any more recent experiences they would like to share?
42 Replies
Entity Framework? No
Entity Framework Core? Yes
look into Dapper
as an alternative
If you like writing SQL queries by hand, then sure, look into Dapper
If you never wish to see SQL again, use EF Core
entity framework is the older and "bad" way to do things now
entity framework core on the other hand is better
but theres also things like dapper if you wanna write sql yourself which can be a pain sometimes
migrations disagree
i havent needed to touch migrations with sql ever
even they are in c# code
Never needed to touch them much either
Just generate, apply, done
you're still writing SQL inside the C# methods though
except when you rename a table and change a type of it at the same time
And even if I had to edit some migration, it's written in C#, with barely any SQL here and there
and you need to know what the migrations mean if you want to debug in case something doesn't go right
thats LINQ not sql
no, your migrations have
Up
and Down
methods that contain the SQL necessary to do the migrationsno? thats all c#
listen, I'm not saying EF Core is bad, on the contrary
but Dapper is worth checking out especially when working closer to the metal
ef core provides methods to execute raw sql as well
yeah but it's a waste to use EF Core for that
either use EF Core to its full extent or stick with Dapper to quickly bash out results
also with dapper you are forced to write repositories if you want it easy to use
ef core and repositories is a very dividing opinionated topic
Point me to SQL code in any of my migrations, please: https://github.com/Genfic/Ogma/blob/master/Ogma3/Migrations/20200830201309_ImprovedDocumentsHistory.cs
you can make it as easy or as abstract as you want
okay my bad, they are indeed C# methods that just happen to execute 1-to-1 SQL queries
GitHub
Ogma/Ogma3/Migrations/20200830190701_DocumentsHistory.Designer.cs a...
Publish your stories, talk about them, categorize them to your heart's content - Genfic/Ogma
stuff like
character varying
and bigint
are things you have to know about the specific DB you're using
so you do require the lower level knowledge to set-up EF Core like it or notUh, not really? I just rely on NpgSQL's type mappings
If it says it's a bigint, it's a bigint
Whatever
iam working with databases using ef core since 3 years and i still havent wrote a single line of sql in my life
ok I corrected myself already, you're not literally writing SQL
you're writing the C# version of them that pretty much follows the same syntax
you aren't writing migrations by hand unless you need some weird custom behavior
like drop table, hascolumntype whatever the heck
the grand majority of the time you just make EFC generate the migration based on what you changed in your model and it just works
dotnet ef migrations add ChangedSomeShit
is how you write a migration lolyeah until it doesn't and you need to debug what happened
that doesn't mean it isn't worth the time savings the rest of the time
that's also not what I'm saying
I've used both EF Core and Dapper, they have different use cases
but saying you don't need to know or understand SQL because migrations are magic is untrue
i'm not saying that either
you shouldn't use EFC to avoid learning sql
you should use it for the convenience and extra type safety it offers
yeah well tell that to Drop and ZZZ
I am using EFC to avoid learning SQL, besides the very basic concepts 😛
several times i've had to debug issues by reading the actual queries being sent to the db
Same
But I feel like reading SQL and writing it are two different beasts
SQL is not as much of a write-only language as Regex, but it's damn close
I had an EF fight this morning. I won't go too much into that argument. I think that devs overall know less about sql than they should. It's less of an EF problem than a skillset problem.
so what you're saying is
skill issue
i may or may not have been fighting EFC all day to get an overcomplicated solution to a simple problem working
mostly my fault
For using ef
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.