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
  1. Home
  2. The Lounge
  3. Code First, do you like it?

Code First, do you like it?

Scheduled Pinned Locked Moved The Lounge
databasequestion
75 Posts 42 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.
  • S SPoss

    what about different flavours of coffee? does it help? Its normal coffee first (medium don't want to shock the heart to early, got work to do), then mid-morning, may be a orange flavoured coffee or cameral. Just received some Chocolate Mint, but not sure I like this one.

    X Offline
    X Offline
    xiecsuk
    wrote on last edited by
    #60

    SPoss wrote: Just received some Chocolate Mint Ooooh, I just love After Eight Chocolate Mints. That thin layer of dark chocolate hiding the peppermint cream filling. Gorgeous!!!

    1 Reply Last reply
    0
    • W WiganLatics

      BaconSandwichFirst

      X Offline
      X Offline
      xiecsuk
      wrote on last edited by
      #61

      But then you would being from the right side of the Pennines!! That's if I read your signature right. And like me, I suppose it's tea during the day with a single cup of coffee after one's evening meal.

      1 Reply Last reply
      0
      • R RUs123

        I'm more of a coffee first developer.

        A Offline
        A Offline
        Anna Jayne Metcalfe
        wrote on last edited by
        #62

        Think of it as #caffeinedrivendevelopment in action.

        Anna (@annajayne) Tech Blog | Visual Lint "Why would anyone prefer to wield a weapon that takes both hands at once, when they could use a lighter (and obviously superior) weapon that allows you to wield multiple ones at a time, and thus supports multi-paradigm carnage?"

        1 Reply Last reply
        0
        • L Layinka

          I am not sure how this can happen. If you were using Entity framework, i know this can't happen. EF will inform you that the database and the POCO are out of sync. Also, EF7 is strictly going to be Code first, though you have the option of generating the classes form an already existing db, but after that code first. I think i prefer code first a lot, its very RAD, and migrations allow me to tweak almost anything nowadays.

          S Offline
          S Offline
          Slacker007
          wrote on last edited by
          #63

          Layinka wrote:

          EF7 is strictly going to be Code first

          Good to know.

          1 Reply Last reply
          0
          • S Slacker007

            We are thinking about moving from database first, to code first, with our new projects.

            B Offline
            B Offline
            boarderstu
            wrote on last edited by
            #64

            My initial question is why? What are you going to gain? Etc..

            1 Reply Last reply
            0
            • S Slacker007

              We are thinking about moving from database first, to code first, with our new projects.

              U Offline
              U Offline
              User 12206071
              wrote on last edited by
              #65

              I like Break Before and After Code

              1 Reply Last reply
              0
              • S Slacker007

                We are thinking about moving from database first, to code first, with our new projects.

                N Offline
                N Offline
                Nathan Minier
                wrote on last edited by
                #66

                No, I love it. Bearing in mind that my application client base is small-to-mid organizations and so I'm not as concerned with specific database optimizations. And as a dev on a small team I'm just fine with that, because POCOs support my notion that a database is just where I keep my stuff. The primary motivator, on my side, is that they make Abstracting the DAL trivial. If we choose to move to Mongo or Couch at some point, I can just re-implement my IDataContext rather than re-write every single model. I only have 2 real gripes: first is that my preferred TPT hierarchy can result in some very hard to debug queries, and switching from int to GUID indexing can be a giant pain in the rear.

                S 1 Reply Last reply
                0
                • N Nathan Minier

                  No, I love it. Bearing in mind that my application client base is small-to-mid organizations and so I'm not as concerned with specific database optimizations. And as a dev on a small team I'm just fine with that, because POCOs support my notion that a database is just where I keep my stuff. The primary motivator, on my side, is that they make Abstracting the DAL trivial. If we choose to move to Mongo or Couch at some point, I can just re-implement my IDataContext rather than re-write every single model. I only have 2 real gripes: first is that my preferred TPT hierarchy can result in some very hard to debug queries, and switching from int to GUID indexing can be a giant pain in the rear.

                  S Offline
                  S Offline
                  Slacker007
                  wrote on last edited by
                  #67

                  Nathan Minier wrote:

                  I only have 2 real gripes: first is that my preferred TPT hierarchy can result in some very hard to debug queries, and switching from int to GUID indexing can be a giant pain in the rear.

                  but obviously this is not so great a hindrance, that you don't use code first.

                  N 1 Reply Last reply
                  0
                  • S Slacker007

                    Nathan Minier wrote:

                    I only have 2 real gripes: first is that my preferred TPT hierarchy can result in some very hard to debug queries, and switching from int to GUID indexing can be a giant pain in the rear.

                    but obviously this is not so great a hindrance, that you don't use code first.

                    N Offline
                    N Offline
                    Nathan Minier
                    wrote on last edited by
                    #68

                    They're gripes, not deal-breakers. I enjoy the ability to abstract the DAL in this way, it just makes sense to me and the flexibility is nice. I forgot to mention earlier, a lot of the specific tweaking can also be separated from the Model using the Fluent API. You can apply all sorts of configurations and settings in the OnModelCreating() function of a DbContext, although I prefer to use a derivative of the EntityTypeConfiguration to tag classes for export, configure the SQL properties, and let MEF figure it out :)

                    1 Reply Last reply
                    0
                    • V Vark111

                      Neither. I prefer to hand create both. Call me old school, but I don't trust auto created databases or entity layers. Too many times someone makes a "minor" tweak to one or the other and then forgets to regenerate, then you're hosed.

                      P Offline
                      P Offline
                      PSU Steve
                      wrote on last edited by
                      #69

                      Old school here too. I can't recall the last time I let either DB or code be auto-created for me.

                      1 Reply Last reply
                      0
                      • S Slacker007

                        We are thinking about moving from database first, to code first, with our new projects.

                        J Offline
                        J Offline
                        Josh Go
                        wrote on last edited by
                        #70

                        It's a step in the right direction. You should not be picking your database early on in the project, that's an architectural decision that could have a lasting impact, and cause lots of headaches. In my experience starting with the DB leads to poorly designed classes. Design/model the problem, then figure out how you want to store it. You should watch this video by Uncle Bob: Robert C. Martin - Clean Architecture on Vimeo[^] Basically, you want to focus on the business model/problem and defer a lot of these big architectual decisions until you get a good understanding of the problem. Eventually you want to get to just a design/modeling phase, where you get the "business owners" and "technical owners" talking in one room, and hashing it out together. No code involved here, just whiteboard and lots of talking.

                        S 1 Reply Last reply
                        0
                        • J Jacquers

                          I still prefer to design the database the traditional way, but the migrations that code first uses are pretty cool.

                          P Offline
                          P Offline
                          Pat Capozzi
                          wrote on last edited by
                          #71

                          I built a large project with code first using MS MVC (a couple of years ago) and felt that I addressed one of the major problems in programming. One of my basic rules of project development has been YOU BETTER GET YOUR DATABASE DESIGNED FIRST OR YOU WILL REALLY DESTABILIZE THE APP WHEN YOU MAKE CHANGES TO THE DB MIDSTREAM. Sometimes, however, you just don't have that luxury and Code First really helps in that scenario. With code first you focus on your classes and so you can work and think at a truly theoretical level. Changes to classes and new classes migrate to the DB at the push of a button and so there is never any lag between design and implementation when making design changes. That is the high level view. You are free to work and think at a class level. The companion to code first is LINQ. With code first and LINQ you can literally design and built a complex system and never even look at the database. It is a very cool experience. There are some considerations. The key one is test data. When you 'recycle' your DB after class / design changes you often need to migrate test data. When I was working on my code first project, MS had some data migration hooks but I just ended up building a routine to re-populate the test data. I am sure it is better now. I felt Code First was a useful technique when building a system from the ground up.

                          1 Reply Last reply
                          0
                          • D Duncan Edwards Jones

                            Not really, no. It feels better to start with but when you have a decent size model you basically have no way to visualise it except turning it into a database and then looking at that.

                            W Offline
                            W Offline
                            WildlingCoder
                            wrote on last edited by
                            #72

                            I have seen the many-tentacled monsters manifested from the murky depths of Code First. Epi's with their SAS armor fear to step within the shadow of these Lovecraftian beasts. The Oracles on high, throw ever more power against it, and the leviathan will not be sated. When it takes 109 left joins, 20 sub-selects and 17 decodes to pull a single death record, there is nothing but eye-clawing madness and sound of your own screaming. So... no. I do not like Code First.

                            1 Reply Last reply
                            0
                            • J Josh Go

                              It's a step in the right direction. You should not be picking your database early on in the project, that's an architectural decision that could have a lasting impact, and cause lots of headaches. In my experience starting with the DB leads to poorly designed classes. Design/model the problem, then figure out how you want to store it. You should watch this video by Uncle Bob: Robert C. Martin - Clean Architecture on Vimeo[^] Basically, you want to focus on the business model/problem and defer a lot of these big architectual decisions until you get a good understanding of the problem. Eventually you want to get to just a design/modeling phase, where you get the "business owners" and "technical owners" talking in one room, and hashing it out together. No code involved here, just whiteboard and lots of talking.

                              S Offline
                              S Offline
                              Slacker007
                              wrote on last edited by
                              #73

                              Josh Go wrote:

                              you want to focus on the business model/problem and defer a lot of these big architectual decisions until you get a good understanding of the problem.

                              :thumbsup:

                              1 Reply Last reply
                              0
                              • S Slacker007

                                We are thinking about moving from database first, to code first, with our new projects.

                                C Offline
                                C Offline
                                canoeman
                                wrote on last edited by
                                #74

                                I do not like Code First. Database First encourages one to carefully consider the modelling with considerations for normalization and database performance (which is often a bottleneck in systems). There are also many tools out there for modelling databases which makes visualizing and collaborating on the model easier. Finally, I just don't trust Code First to make the right decision for generating schemas for large or slightly complex models.

                                1 Reply Last reply
                                0
                                • S Slacker007

                                  We are thinking about moving from database first, to code first, with our new projects.

                                  R Offline
                                  R Offline
                                  rjemp
                                  wrote on last edited by
                                  #75

                                  As with most such question, I think the best answer is 'it depends'. I've found code first very useful when building out a smallish self-contained system (an android app with a .net / sql backend), which has about 15 tables and is unlikely to grow. The beauty has been that I can keep coding, adding things to the models as I prototype and get feedback, think of things I've forgotten, and don't have to muck around with sqlscripts. Simply add-migration from the package console and job done. However, once that system goes into production I will revert to a traditional approach. On other bigger, more complex projects, where you have a logical schema with ~200 tables, there is no way I would do that code first.

                                  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