Is Entity Framework 4.x the right tool for developing in a brownfield environment? [closed]
Is Entity Framework 4.x the right tool to use when developing or updating code in a brownfield situation?
What realistic productivity gains can I expect over just writing against the DB?
I would appreciate any opinions.
Maybe? It's going to really depend on the situation.
If you're writing a new module to plug into the app, that's probably the easiest case to use EF because you'll be able to isolate it in that new area. I found massive productivity gains when I switched to it vs writing against the DB directly (or using stored procedures, or whatever). Literally cut the time to do many tasks in half and eliminated a large amount of highly repetitive code.
The big gains for productivity are in things like not having to write classes (since you already have a database you can tell EF to use it and it'll create the entities and classes for you), and then in not having to write queries. I always find writing the highly repetitive queries error prone just due to typos, and your CRUD operations are all taken care of for you.
It's a bit different if you're taking something existing and trying to shoehorn EF into it, and there's a lot of "it depends" in there. It might help you out a lot if there are things that are easy to replace. But if you're going to wind up with a confusing mix where in one function you do some stuff to the DB in EF and then do some more stuff to the same DB by hitting it directly using the old way? For someone else working on the app later it's going to be difficult to understand what's going on and how all the moving parts interact.
Swapping it in also may mean tossing out already working code to hit the DB, so the productivity gain isn't as high as when you're starting fresh since in this case you already have a working solution. Might still be worth it though.
精彩评论