News for hackers. Stuff that matters.
Re:Migrating to Postgres by pier25 on Wednesday May 14, 2025 @08:42PM (#43990674)
> I can't stand ORMs, I don't get why people use it, please just write the SQL.

I used to agree until I started using a good ORM. Entity Framework on .NET is amazing.

Re:Migrating to Postgres by bob1029 on Wednesday May 14, 2025 @09:00PM (#43990794)
> Entity Framework on .NET is amazing.

I disagree. It is probably one of the less terrible ORMs, but it is far from amazing. The object-relational impedance mismatch will always dominate for anything that isn't trivial business. EF works great until you need different views of the model. It does support some kind of view mapping technique, but it's so much boilerplate I fail to see the point.

Dapper + SqlConnection is goldilocks once you get into the nasty edges. Being able to query a result set that always exactly matches your view models is pretty amazing. The idea of the program automagically upgrading and migrating the schemas is something that was interesting to me until I saw what you could accomplish with Visual Studio's SQL Compare tool & RedGate's equivalent. I feel a lot more comfortable running manual schema migrations when working with hosted SQL providers.

Re:Migrating to Postgres by cyral on Wednesday May 14, 2025 @09:06PM (#43990823)
> It does support some kind of view mapping technique

Can you call .Select(entity => SomeSmallerModel() { Name = entity.Name }) or something like that to select what you need? If I am understanding your issue correctly.

I also agree that its one of the least worst but there are still things that annoy me.

Re:Migrating to Postgres by neonsunset on Wednesday May 14, 2025 @09:05PM (#43990819)
> EF works great until you need different views of the model

You can easily project or use views with SQL then projected onto objects. It's very convenient with `.FromSql`:

https://learn.microsoft.com/en-us/ef/core/querying/sql-queri...

Re:Migrating to Postgres by pier25 on Thursday May 15, 2025 @12:29AM (#43991855)
> I feel a lot more comfortable running manual schema migrations

Me too. I use a DB-first approach. Then EF simply rebuilds the application models automatically with a single command.

Re:Migrating to Postgres by tilne on Wednesday May 14, 2025 @08:50PM (#43990730)
Doesn’t entity framework have a huge memory footprint too?
Re:Migrating to Postgres by neonsunset on Wednesday May 14, 2025 @09:07PM (#43990826)
Do you have any links that note memory usage issues with any of the semi-recent EF Core versions?
Re:Migrating to Postgres by tilne on Thursday May 15, 2025 @07:28AM (#43993888)
No. To be clear: I wasn’t trying to say it was bad. Just repeating what I had read in a (fairly old) .net book. Should have chosen my words more carefully.
Re:Migrating to Postgres by neonsunset on Thursday May 15, 2025 @08:54AM (#43994523)
To be fair, old Entity Framework was on the heavier side. Still much faster than e.g. ActiveRecord but enough for Dapper to be made back then. The gap between them is mostly gone nowadays plus .NET itself has become massively faster and alternate more efficient alternatives got introduced since (Dapper AOT, its main goal is NAOT compatibility but it also uses the opportunity to further streamline the implementation).
Re:Migrating to Postgres by tilne on Thursday May 15, 2025 @09:47AM (#43995054)
Thanks for the context. I’m new to the ecosystem, so it’s valuable to hear thoughts like these from people with more experience with it.
Re:Migrating to Postgres by homebrewer on Thursday May 15, 2025 @06:47AM (#43993654)
If you don't do stupid things like requesting everything from the database and then filtering data client side, then no.

We have one application built on .NET 8 (and contemporary EF) with about 2000 tables, and its memory usage is okay. The one problem it has is startup time: EF takes about a minute of 100% CPU load to initialize on every application restart, before it passes execution to the rest of your program. Maybe it is solvable, maybe not, I haven't yet had the time to look into it.

Re:Migrating to Postgres by tilne on Thursday May 15, 2025 @07:26AM (#43993878)
Yeah makes sense. I should have used my language more carefully: I have very little hands-on experience with entity framework, and thus don’t have objective reasons to say it has a “huge” memory footprint.

Does the startup time/CPU usage cost vary depending on the size of the dataset you’re interacting with?

Re:Migrating to Postgres by neonsunset on Thursday May 15, 2025 @10:16AM (#43995343)
Hmm, it should not be taking this much time unless you're running into an edge case - we have a fairly complex application that needs to pre-load a lot of data from persistence (no EFC though, it's an embedded DB) and over the wire at startup, and it still takes 15 seconds on a rainy day, mostly waiting for requests to finish. If you can gather a profile it will likely shed some light on why this takes place. Worst case, if you have a repro, it's worth to file an issue at https://github.com/dotnet/efcore. When you have time that is.