5 ms·
> ORM? EF Core is pretty good. We're moving to .Net, and I was surprised by how poor the built-in DB stuff is. It's like either assembly or Python, but nothing
by magicalhippo 4y ago
> ORM? EF Core is pretty good.
We're moving to .Net, and I was surprised by how poor the built-in DB stuff is. It's like either assembly or Python, but nothing in the middle.
That said I've also been impressed about how nice it is to get stuff going. I used C# back in the .Net 1.1 days and yeah massive difference in ergonomics.
- alexzeitler 4y agoWhat would you like build-in db stuff to be like?
- magicalhippo 4y agoWell I mean DataTable and friends can handle master-detail for example, but you gotta do a lot of plumbing to set it all up, especially with autoincs involved. Was kinda expecting it to be less work. Ideally I'd like to supply some selects, fill up some DataTables with master-detail data, manipulate it and commit changes. But yeah, maybe I gotta check out the latest EF stuff and see if I can't convince the others...
- edandersen 4y agoDataTables are a construct from .NET Framework 1.1. You owe yourself (and would be doing your employer a massive favour) to check out EF Core.
- magicalhippo 4y agoWell that'd explain why they feel clunky :D Will def look at it more carefully.
- zip1234 4y agoEF Core: 1. load order and related line items 2. edit anything 3. call SaveChanges() Definitely check it out if you haven't recently!
- andix 4y agoJust do yourself a favor and don’t use datatables directly. If you want to be as close to the database as possible, check out Dapper. It EF core should cover nearly all Dapper functionality and much more.
- tester756 4y ago>It's like either assembly or Python, but nothing in the middle. Dapper seems to be in the middle and it is pretty popular
- magicalhippo 4y agoYeah, but from what I saw it doesn't help much with master-detail setups? Like, inserting or updating an order with order lines etc. We rely heavily on those.
- tester756 4y agoIt is pure SQL, so it should, I think?
- NicoJuicy 4y agoUse transactions => fails rollback. No need to correct failures. Important concepts: .NoTracking and setting the EntityState correctly ( mark as deleted, updated, ... ) Additionally, sometimes it's easier to update things granularly, instead of all at once. I suppose the annoyance comes from updating in bulk on a POST and trying to map everything?
- jug 4y agoMaybe also check PetaPoco. But at this point you're getting closer and closer to code-first EF Core anyway. :) https://github.com/CollaboratingPlatypus/PetaPoco https://github.com/CollaboratingPlatypus/PetaPoco
- Zecc 4y agoI haven't actually tried either Dapper or PetaPoco, only perused their documentation. But I was sold on LinqToDb after seeing how it supported CTE and seeing our close code to generate updates [1] and joins [2] ended up looking like the actual intended SQL. [1]: https://linq2db.github.io/#update [2]: https://linq2db.github.io/articles/sql/Join-Operators.html
- 4y ago
- 0xDEF 4y ago>We're moving to .Net, and I was surprised by how poor the built-in DB stuff is Right now EF Core is probably the best ORM that has ever existed. What exactly is missing? Although for performance you would probably reach for something like Dapper but that is not an ORM.
- magicalhippo 4y agoWell that was my point, either you're writing a lot of code yourself ("assembly"), or you use EF ("Python"). We're not used to something like EF, perhaps it would work for us. But debugging generated queries due to performance issues is something we'd like to avoid. For now the decision was made to not use EF.
- NicoJuicy 4y agoEF handles migration and you can re-use the DbConnection and execute plain SQL. If you don't want to debug difficult queries, then extend it to use Dapper and use the best of both worlds.
- andix 4y agoYou don’t have to use migrations, it’s an optional feature. It works equally well to just generate entities from an existing database, that is migrated/set-up in any other way (as long as the schema is not crazily complex).
- other_herbert 4y agoNot my project/not affiliate but Evolve is wonderful for handling db migrations
- NicoJuicy 4y agoHaven't heard of Evolve before, but used DbUp in the past with success too: https://dbup.readthedocs.io/en/latest/ https://dbup.readthedocs.io/en/latest/
- cyral 4y agoEF Core when it first came out was pretty rough but they have been adding a ton, especially in .NET 7 and coming up with 8: https://learn.microsoft.com/en-us/ef/core/what-is-new/ef-core-7.0/whatsnew https://learn.microsoft.com/en-us/ef/core/what-is-new/ef-cor... Most of the pain points for me are solved now. Like someone else mentioned, Dapper can fill the gaps.
- bottlepalm 4y agoI'd kill for anything close to EF for Node. Selecting complex structures from a database in any of the existing JS ORMs is just painful.
- banashark 4y agoI've enjoyed the ORM in adonisjs: https://docs.adonisjs.com/guides/models/relationships#preload-nested-relationships https://docs.adonisjs.com/guides/models/relationships#preloa... Having used it on an actual product and dealing with some of the pain points, it's my go-to since the typescript version (v5) came out. The ORM uses Knex.js internally, which is very simple to drop into if you just want a query builder. Having Knex be accessible also makes it simple to just write your query in plain sql as well, or as the Lucid ORM has available, just fragments of your query (say the join statement) as raw sql: https://docs.adonisjs.com/reference/database/query-builder#whereraw https://docs.adonisjs.com/reference/database/query-builder#w... Along with debugging, printing out the sql, and support via the Adonisjs REPL "Ace", it makes for a very nice experience.
- bottlepalm 4y agoThese are more akin to Dapper which is a thin layer on top of SQL. Currently I use Prisma for JS, it's a bit better, but if you haven't used EF then you probably don't know what you're missing.
- banashark 4y agoI've used EF quite a bit in the past. While there may be some features missing, Lucid an ActiveRecord implementation, which I would figure would fall into the "ORM" category. Which features would you say are the key ones that make Lucid seem more like a query mapper (Dapper, Knex) than an ORM (ActiveRecord, EF)? Specifically, in my Adonis projects, I'm mostly working with the Model objects through the ORM methods, and only dropping to Knex/SQL when necessary (complex CTE, etc). Since it's such a Model-centric seeming way of development, it naturally seems like an Object-Relational Mapping to me.
- pjmlp 4y agoI am just old fashioned, as much stored procedures as possible, why waste network traffic.