logoalt Hacker News

bob1029yesterday at 1:00 AM3 repliesview on HN

> 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.


Replies

cyralyesterday at 1:06 AM

> 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.

pier25yesterday at 4:29 AM

> 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.

neonsunsetyesterday at 1:05 AM

> 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...