Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. The Lounge
  3. EF - CodeFirst.... not so much.

EF - CodeFirst.... not so much.

Scheduled Pinned Locked Moved The Lounge
csharpdatabasejson
15 Posts 8 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Mycroft Holmes

    Every time I see a rant like this it reinforces my decision not to use EF, the mind boggles that you could allow a tool to create your database. Having dealt with MS click once deployment and trying to find the app files I shudder to think what their DB would look like.

    Never underestimate the power of human stupidity RAH

    D Offline
    D Offline
    Dave Kreskowiak
    wrote on last edited by
    #6

    The database it makes is actually very straight forward and easy to follow, at least if going the CodeFirst route. It creates the tables and fields with names mirroring your classes almost exactly the same. The differences being where relationships come in. In that case, a name will always have the format ClassName_ClassProperty for FKs. It really doesn't "put everything everywhere".

    A guide to posting questions on CodeProject[^]
    Dave Kreskowiak

    M 1 Reply Last reply
    0
    • G George H Slaterpryce III

      the more I work with entity framework, the more I dislike it. it's REALLY easy on the developer side of the equation, but from a DBA standpoint... it REALLY sucks. sure I can serialize an object to a database... but Oh my god it puts things EVERYWHERE. I can "Configure" the way it works... sorta, using the FLuent API... but I might as well do an old school ADO.net DAL for all the extra PITA that gives me. Grrr.

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #7

      Wow. My experience goes back 6 months, and I find that it definitely does NOT "put everything everywhere", at least on the database side. It puts everything where I would expect it to, but then again, I'm not a DBA by trade. But, if you were talking about where EF CodeFirst code goes, then it does get a little wild. Updating the Context(s) with DbSets takes a bit planning and documentation to keep straight, as well as your own custom Initializers, Models, wrapper classes (UnitOfWork), ... But, I've put all of that in its own project to keep it organized. Though, I agree with your assessment of the Configuration API. It's a bit difficult to wrap my brain around it, but I've managed to get an 80 table database running without too much of a headache, using about 25 explicit relationship configurations in four classes. One table has 18 relationships going to it but I only had to manually configure seven of them. But, as with every framework that relies on Convention to write code and automate tasks for you, it's no different than any other in its complexity.

      A guide to posting questions on CodeProject[^]
      Dave Kreskowiak

      1 Reply Last reply
      0
      • G George H Slaterpryce III

        the more I work with entity framework, the more I dislike it. it's REALLY easy on the developer side of the equation, but from a DBA standpoint... it REALLY sucks. sure I can serialize an object to a database... but Oh my god it puts things EVERYWHERE. I can "Configure" the way it works... sorta, using the FLuent API... but I might as well do an old school ADO.net DAL for all the extra PITA that gives me. Grrr.

        R Offline
        R Offline
        R Giskard Reventlov
        wrote on last edited by
        #8

        Used it on a large project and a few smaller ones but now gone back to ADO.

        "If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." Red Adair. Those who seek perfection will only find imperfection nils illegitimus carborundum me, me, me me, in pictures

        1 Reply Last reply
        0
        • G George H Slaterpryce III

          the more I work with entity framework, the more I dislike it. it's REALLY easy on the developer side of the equation, but from a DBA standpoint... it REALLY sucks. sure I can serialize an object to a database... but Oh my god it puts things EVERYWHERE. I can "Configure" the way it works... sorta, using the FLuent API... but I might as well do an old school ADO.net DAL for all the extra PITA that gives me. Grrr.

          N Offline
          N Offline
          Nicolas Dorier
          wrote on last edited by
          #9

          I am using ADO.NET + data contract serialized blob approach. That way, queries stays close enough to SQL. And I have some flexibility to change data format without impacting the table structure, and existing clients, thus making deployment easier. Also, I get the benefit of intellisense on the data in the blob column. :) That said, EF code first is cool for doing websites without messing up with SQL. But sometimes messing up with SQL is the simplest way. (And in my case, it is often the case)

          1 Reply Last reply
          0
          • D DaveAuld

            Expand on `it puts things everywhere`.... What are you trying to manage that is making it a PITA?

            Dave Find Me On: Web|Facebook|Twitter|LinkedIn


            Folding Stats: Team CodeProject

            G Offline
            G Offline
            George H Slaterpryce III
            wrote on last edited by
            #10

            In this instance I had one table that had entries that multiple other tables had one to many relationships with. They way EF mapped this out was... interesting, and less than efficient. for example CustomerAddresses VendorAddresses Instead of having just a CustomerID and AddressID in another table, had the whole of the address class stored in each of these tables, instead of one single address table. There are other cases. and this case was something that can be overcome, but it's just a pita.

            1 Reply Last reply
            0
            • D Dave Kreskowiak

              The database it makes is actually very straight forward and easy to follow, at least if going the CodeFirst route. It creates the tables and fields with names mirroring your classes almost exactly the same. The differences being where relationships come in. In that case, a name will always have the format ClassName_ClassProperty for FKs. It really doesn't "put everything everywhere".

              A guide to posting questions on CodeProject[^]
              Dave Kreskowiak

              M Offline
              M Offline
              Mycroft Holmes
              wrote on last edited by
              #11

              If the naming of a FK is the worst it does then I don't see the problem. Personally I'm a data structure first builder, I have trouble conceiving of a code first application. Considering 90% of my work is based on LOB massaging of huge chunks of data I guess this is understandable. I still won't entertain the idea of Ef in our apps!

              Never underestimate the power of human stupidity RAH

              1 Reply Last reply
              0
              • R Rutvik Dave

                I understand that almost all the 'new approaches' can be a pain in the initial learning phase. But it eventually makes sense. I had the same problem with MVC and jQuery. :) On the contrast side. EF Code first approach is very useful when you want to update database on your cloud-based application after it's been already launched. If you are not using Code First approach then you will have to update the database first (manually) and then push the code changes, which will cause a downtime. But if you are using code first approach, it can seamlessly push the code and database changes with almost no downtime. I have a cloud-based application hosted on Azure where I am not using the codefirst approach. and every update to the application is tedious if it involves database changes.

                George H. Slaterpryce III wrote:

                Oh my god it puts things EVERYWHERE.

                I don't understand, what do you mean by everywhere?

                Remind Me This - Manage, Collaborate and Execute your Project in the Cloud

                G Offline
                G Offline
                George H Slaterpryce III
                wrote on last edited by
                #12

                I've never hosted an application on the cloud. But Codefirst doesn't support migration so I would be interested to see how it would be easier.

                R 1 Reply Last reply
                0
                • S Septimus Hedgehog

                  I don't think anybody ever suggested that EF does things how you want. We tried it once and like the proverbial good-natured bobby would say; "move along folks, there's nothing to see." :)

                  If there is one thing more dangerous than getting between a bear and her cubs it's getting between my wife and her chocolate.

                  G Offline
                  G Offline
                  George H Slaterpryce III
                  wrote on last edited by
                  #13

                  Problem is, I'm relatively new to EF / CF. It's a technology I just don't use in my normal day to day development. The technology seems to be trending high enough that I should probably become more familiar with it. The project I'm working on now is a bootstrap project. One of those projects you have to do every once in a while to keep up with current practices. I'm constantly fighting the little gremlin on my shoulder screaming "Why are you doing it this way?!, it would take you five friggin minutes to do it the old way!". Because if I didn't I would never keep up. Now, after I feel comfortable enough with the tech, I might not use it again, but until I learn it well enough that I could Teach (Which is a looooooooong way away) it. I'll hold off final judgement.

                  1 Reply Last reply
                  0
                  • G George H Slaterpryce III

                    I've never hosted an application on the cloud. But Codefirst doesn't support migration so I would be interested to see how it would be easier.

                    R Offline
                    R Offline
                    Rutvik Dave
                    wrote on last edited by
                    #14

                    George H. Slaterpryce III wrote:

                    But Codefirst doesn't support migration

                    It certainly does[^]. :) (...or we are not talking about the same thing.)

                    Remind Me This - Manage, Collaborate and Execute your Project in the Cloud

                    G 1 Reply Last reply
                    0
                    • R Rutvik Dave

                      George H. Slaterpryce III wrote:

                      But Codefirst doesn't support migration

                      It certainly does[^]. :) (...or we are not talking about the same thing.)

                      Remind Me This - Manage, Collaborate and Execute your Project in the Cloud

                      G Offline
                      G Offline
                      George H Slaterpryce III
                      wrote on last edited by
                      #15

                      Huh, all the books and documents I've been reading said it didn't.... cool! thanks for the info.

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups