C
C#7mo ago
Wycott

❔ 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
Angius
Angius7mo ago
Entity Framework? No Entity Framework Core? Yes
JansthcirlU
JansthcirlU7mo ago
look into Dapper as an alternative
Angius
Angius7mo ago
If you like writing SQL queries by hand, then sure, look into Dapper If you never wish to see SQL again, use EF Core
Dropps
Dropps7mo ago
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
JansthcirlU
JansthcirlU7mo ago
migrations disagree
Dropps
Dropps7mo ago
i havent needed to touch migrations with sql ever even they are in c# code
Angius
Angius7mo ago
Never needed to touch them much either Just generate, apply, done
JansthcirlU
JansthcirlU7mo ago
you're still writing SQL inside the C# methods though
Dropps
Dropps7mo ago
except when you rename a table and change a type of it at the same time
Angius
Angius7mo ago
And even if I had to edit some migration, it's written in C#, with barely any SQL here and there
JansthcirlU
JansthcirlU7mo ago
and you need to know what the migrations mean if you want to debug in case something doesn't go right
Dropps
Dropps7mo ago
thats LINQ not sql
JansthcirlU
JansthcirlU7mo ago
no, your migrations have Up and Down methods that contain the SQL necessary to do the migrations
Dropps
Dropps7mo ago
no? thats all c#
JansthcirlU
JansthcirlU7mo ago
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
Dropps
Dropps7mo ago
ef core provides methods to execute raw sql as well
JansthcirlU
JansthcirlU7mo ago
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
Dropps
Dropps7mo ago
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
JansthcirlU
JansthcirlU7mo ago
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
JansthcirlU
JansthcirlU7mo ago
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 not
Angius
Angius7mo ago
Uh, not really? I just rely on NpgSQL's type mappings If it says it's a bigint, it's a bigint Whatever
Dropps
Dropps7mo ago
iam working with databases using ef core since 3 years and i still havent wrote a single line of sql in my life
JansthcirlU
JansthcirlU7mo ago
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
Jimmacle
Jimmacle7mo ago
you aren't writing migrations by hand unless you need some weird custom behavior
JansthcirlU
JansthcirlU7mo ago
like drop table, hascolumntype whatever the heck
Jimmacle
Jimmacle7mo ago
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
Angius
Angius7mo ago
dotnet ef migrations add ChangedSomeShit is how you write a migration lol
JansthcirlU
JansthcirlU7mo ago
yeah until it doesn't and you need to debug what happened
Jimmacle
Jimmacle7mo ago
that doesn't mean it isn't worth the time savings the rest of the time
JansthcirlU
JansthcirlU7mo ago
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
Jimmacle
Jimmacle7mo ago
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
JansthcirlU
JansthcirlU7mo ago
yeah well tell that to Drop and ZZZ
Angius
Angius7mo ago
I am using EFC to avoid learning SQL, besides the very basic concepts 😛
Jimmacle
Jimmacle7mo ago
several times i've had to debug issues by reading the actual queries being sent to the db
Angius
Angius7mo ago
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
Mayor McCheese
Mayor McCheese7mo ago
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.
JansthcirlU
JansthcirlU7mo ago
so what you're saying is skill issue
Jimmacle
Jimmacle7mo ago
i may or may not have been fighting EFC all day to get an overcomplicated solution to a simple problem working mostly my fault when
Mayor McCheese
Mayor McCheese7mo ago
For using ef
Accord
Accord7mo ago
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.
Want results from more Discord servers?
Add your server
More Posts