Code First
-
Entity Framework in agile environment - Design and Architecture Discussion Boards[^] Was reading this thread. Just want to really know, is there really someone who's using Code-first as the standard approach in their project? I've been trying to do this, but somehow the team environment/people rushes towards DB first. Even our boss is not so keen in getting to this :) Is this something we should definitely aspire to achieve or it's okay to continue with DB first approach?
There's a lot of waffle in the responses but the truth is as it is for most things... It depends on what you're developing. Some people have alluded to this. I have worked on projects that have used code first effectively. No performance bottlenecks, easy deployments, very neat code. Easy to follow and all in one place. If you have a fairly simple schema to create, code first is not going to be a problem. If you have a more complex schema, then you may have to evaluate it a bit more. I have worked on projects that code the DB first. This gives you the most control and is the more consisitent approach when writing stored procedures, triggers and other object types. If using Visual Studio (assuming as you're using EF) and if you're also using SQL Server then Visual Studio DB projects are great for modelling databases and doing quick and easy deployments. ORMs are great but use with a little caution as you may introduce unnecessary overheads. In summary, to answer your question more directly, yes code first is used for real applicstions/projects. On the question of whether to aspire to it, I do not believe it should be considered a standard or any sort of evolution of development - you would use it based on the merits for your application.
-
Entity Framework in agile environment - Design and Architecture Discussion Boards[^] Was reading this thread. Just want to really know, is there really someone who's using Code-first as the standard approach in their project? I've been trying to do this, but somehow the team environment/people rushes towards DB first. Even our boss is not so keen in getting to this :) Is this something we should definitely aspire to achieve or it's okay to continue with DB first approach?
We always do code first, but we also follow a very strict and sane DB design principle. "Everything is flat by design and we optimize for lowest complexity." Juniors that optimize for "This is going to be faster and/or more efficient" are getting stabbed with a knife by me personally. People prefer DB first, because they like to decide what the data should look like.. which is also fundamentally wrong. Data already has a defined structure when it gets into your system, and has a defined structure when it comes out. All you need to do is flatten it in a safe way, so you can persistently store it, when it's in between those 2 states. The worst of the bunch are Enterprise folks that go on and on about Business Objects or Domain Objects. They're willfully ignoring their core business (= selling a product or service) in favor of making arbitrary decisions about things they've invented themselves. We call that "having a god complex", because it's fun playing god and creating stuff that people will build for you. I totally get that. But they should do that in Civ5 or something, not at work.
-
This is way too long but your question got me thinking and I just wrote it up. It seems that CodeFirst was a way to get devs to : "Do design in small chunks." Some devs are not going to plan at all. They just start typing code. A lot of those devs were very good at doing this and could really make things happen. But others were terrible at it and created huge maintenance nightmares. So a type of methodology arose out of that which said, "Hey let's make a process out of the idea of typing code. We need to provide a basic process." Just Code It Up In the beginning, many devs just typed code which was imperative in nature -- you tell the code what to do and it does it. Along came OOP. But a lot of devs saw it and just said, "that's a lot of overhead, I can do it faster just by typing up some code" and continued just to "code up a solution". OOP Wave But OOP is about code organization and some people said, "Hey, you need to design things very well and think out everything so you can model the objects in the system and you should have everything planned out so you can go and create the system." But it didn't catch on with a lot of devs because they knew that requirements change and you can't design any large system entirely before building because when you do you miss stuff. But then many devs were like, "Well, we don't want to go back to just coding things up with no plan either." Along Comes Agile Model one domain object and get it working. Get the MVP (minimum viable product) so we can have a bit of design but actually start writing code and having things running very fast. This made the pantsers (coding by the seat of your pants) happy and made the strong OOP devs happier because at least there was some organization and process built into the system. Everything else is just these two factions fighting it out: 1. Pure Agile - (design it on the fly) 2. Heavier process (design more up front / create large domain model ("all" objects in your system)) Reality: Stuck In The Middle Real life is somewhere in between. The Code First thing is a technological process that helps the first group (Pure Agile) to get to what they want with fewer technical barriers. Now they can model an object and it'll be serialized to the database with little work and each time they model a new object their domain model becomes more solid. Of course Code First is also a process that is dev-centric where maybe you have devs that don't have as much experience with dat
-
The bosses always wanted to push the application I am working on to code first. Newer parts work with EF, but there are also more than 20 year old parts that depend on stored procedures. We still need to make changes to the SPs and the data tables. One far away day, when the sun has used up most of its hydrogen and starts to cool down and collapse, we will finaly be rid of all these stored procedures and have EF and the database in a shape that will actually allow code first.
I have lived with several Zen masters - all of them were cats. His last invention was an evil Lasagna. It didn't kill anyone, and it actually tasted pretty good.
EF without "views" and "stored procedures" is like using C# without the .NET framework classes. EF "complements" the database engine; it doesn't "replace" it.
"(I) am amazed to see myself here rather than there ... now rather than then". ― Blaise Pascal
-
Code first is fine for prototyping and knocking out quick things, but it's not suitable for production applications, IMEO.
By definition, a "production" system is past "code first" or "database first"; it's in maintenance mode; which will then probably involve both in one form or another depending on the "fixes" moving forward. A database can have multiple data contexts. A system can have multiple databases. A system "enhancement" can involve adding a new database. Code first or database first?
"(I) am amazed to see myself here rather than there ... now rather than then". ― Blaise Pascal
-
By definition, a "production" system is past "code first" or "database first"; it's in maintenance mode; which will then probably involve both in one form or another depending on the "fixes" moving forward. A database can have multiple data contexts. A system can have multiple databases. A system "enhancement" can involve adding a new database. Code first or database first?
"(I) am amazed to see myself here rather than there ... now rather than then". ― Blaise Pascal
What you described is a production environment, not a production system. By production system I meant an application that is intended to go live and be used in a serious business capacity.
-
Entity Framework in agile environment - Design and Architecture Discussion Boards[^] Was reading this thread. Just want to really know, is there really someone who's using Code-first as the standard approach in their project? I've been trying to do this, but somehow the team environment/people rushes towards DB first. Even our boss is not so keen in getting to this :) Is this something we should definitely aspire to achieve or it's okay to continue with DB first approach?
If starting from scratch, the advantage of "code first" is that the database that is generated "works" with EF. On the other hand, database first assumes you have the smarts to now "confgure" EF to "consume" whatever convoluted schema someone managed to create using "SQL". Now try and keep the 2 in sync. The skill is in knowing when to use which; or both; and transitioning from one to the other.
"(I) am amazed to see myself here rather than there ... now rather than then". ― Blaise Pascal
-
This is way too long but your question got me thinking and I just wrote it up. It seems that CodeFirst was a way to get devs to : "Do design in small chunks." Some devs are not going to plan at all. They just start typing code. A lot of those devs were very good at doing this and could really make things happen. But others were terrible at it and created huge maintenance nightmares. So a type of methodology arose out of that which said, "Hey let's make a process out of the idea of typing code. We need to provide a basic process." Just Code It Up In the beginning, many devs just typed code which was imperative in nature -- you tell the code what to do and it does it. Along came OOP. But a lot of devs saw it and just said, "that's a lot of overhead, I can do it faster just by typing up some code" and continued just to "code up a solution". OOP Wave But OOP is about code organization and some people said, "Hey, you need to design things very well and think out everything so you can model the objects in the system and you should have everything planned out so you can go and create the system." But it didn't catch on with a lot of devs because they knew that requirements change and you can't design any large system entirely before building because when you do you miss stuff. But then many devs were like, "Well, we don't want to go back to just coding things up with no plan either." Along Comes Agile Model one domain object and get it working. Get the MVP (minimum viable product) so we can have a bit of design but actually start writing code and having things running very fast. This made the pantsers (coding by the seat of your pants) happy and made the strong OOP devs happier because at least there was some organization and process built into the system. Everything else is just these two factions fighting it out: 1. Pure Agile - (design it on the fly) 2. Heavier process (design more up front / create large domain model ("all" objects in your system)) Reality: Stuck In The Middle Real life is somewhere in between. The Code First thing is a technological process that helps the first group (Pure Agile) to get to what they want with fewer technical barriers. Now they can model an object and it'll be serialized to the database with little work and each time they model a new object their domain model becomes more solid. Of course Code First is also a process that is dev-centric where maybe you have devs that don't have as much experience with dat
-
DB first usually means there's a "DBA Administrator" in the house; which usually means 6 more months before you "get your database".
"(I) am amazed to see myself here rather than there ... now rather than then". ― Blaise Pascal
Gerry Schmitz wrote:
DB first usually means there's a "DBA Administrator" in the house; which usually means 6 more months before you "get your database".
Very true. The DBA has to get everything right and that takes time. Here's the DBA schedule: 1. 5 months and 3 weeks and 4 days of Candy Crush "work". Must reach level 302!! 2. One day (Friday) of work to design the schema and create the tables on the server. :laugh: :laugh:
-
R1911 wrote:
Article!
Some day. Want to help me write it?
Latest Article - A Concise Overview of Threads Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny Artificial intelligence is the only remedy for natural stupidity. - CDP1802
-
What you described is a production environment, not a production system. By production system I meant an application that is intended to go live and be used in a serious business capacity.
No, I'm describing "systems"; "serious" ones: O&G production; Financials; MRP; etc. And AP, AR, GL, FA ... all systems in the "bigger" Financials (system). Nothing about "environment".
"(I) am amazed to see myself here rather than there ... now rather than then". ― Blaise Pascal
-
EF without "views" and "stored procedures" is like using C# without the .NET framework classes. EF "complements" the database engine; it doesn't "replace" it.
"(I) am amazed to see myself here rather than there ... now rather than then". ― Blaise Pascal
That may be so, but these oldschool SPs designed to be used with DataSets, DataTables and DataRows do not have much in common with the Entity Framework.
I have lived with several Zen masters - all of them were cats. His last invention was an evil Lasagna. It didn't kill anyone, and it actually tasted pretty good.
-
Gerry Schmitz wrote:
DB first usually means there's a "DBA Administrator" in the house; which usually means 6 more months before you "get your database".
Very true. The DBA has to get everything right and that takes time. Here's the DBA schedule: 1. 5 months and 3 weeks and 4 days of Candy Crush "work". Must reach level 302!! 2. One day (Friday) of work to design the schema and create the tables on the server. :laugh: :laugh:
-
Entity Framework in agile environment - Design and Architecture Discussion Boards[^] Was reading this thread. Just want to really know, is there really someone who's using Code-first as the standard approach in their project? I've been trying to do this, but somehow the team environment/people rushes towards DB first. Even our boss is not so keen in getting to this :) Is this something we should definitely aspire to achieve or it's okay to continue with DB first approach?
Because I haven't spent the time to figure out how to code first write Clustered-Primary Key constraint, foreign key cascading rules, some foreign keys without requirement constraint, additional indexes that I can see a mile away. And that one bad time when I first started a code first project, then looked at the database and cried for all the 20+ character long guid names it attached to everything.
-
No, I'm describing "systems"; "serious" ones: O&G production; Financials; MRP; etc. And AP, AR, GL, FA ... all systems in the "bigger" Financials (system). Nothing about "environment".
"(I) am amazed to see myself here rather than there ... now rather than then". ― Blaise Pascal
Quote:
By definition, a "production" system is .. in maintenance mode
That reads to me that you were referring to the environment. If you actually meant "serious" apps, then what you said is that by definition serious apps are in maintenance mode and that makes no sense. That's how I read it anyway.
-
That may be so, but these oldschool SPs designed to be used with DataSets, DataTables and DataRows do not have much in common with the Entity Framework.
I have lived with several Zen masters - all of them were cats. His last invention was an evil Lasagna. It didn't kill anyone, and it actually tasted pretty good.
You're assuming every SP returns a result set; they don't. And a "datatable row" is the equivalent of an entity. One purpose of SP's is to execute logic on the DB server that has no business running on the client. No SP's usually means: simplistic design; or poor design and poor performance.
"(I) am amazed to see myself here rather than there ... now rather than then". ― Blaise Pascal
-
Quote:
By definition, a "production" system is .. in maintenance mode
That reads to me that you were referring to the environment. If you actually meant "serious" apps, then what you said is that by definition serious apps are in maintenance mode and that makes no sense. That's how I read it anyway.
In my world, there is "new development" and "maintenance". (Proposed) "Systems" are analyzed (existing physical and logical); designed (logical and physical); developed; tested; integrated; documented; implemented (i.e. "put into production"); then, turned over for "support and maintenance" (by the group responsible for that area). If you're a one man show, maybe you're always "in development" and don't ever get to "turn it over". Actually, you better be clear knowing where "development" ends and "maintenance" begins: That's what "service contracts" are for (and that's where your long term revenue OR expense comes from).
"(I) am amazed to see myself here rather than there ... now rather than then". ― Blaise Pascal
-
R1911 wrote:
Article!
Some day. Want to help me write it?
Latest Article - A Concise Overview of Threads Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny Artificial intelligence is the only remedy for natural stupidity. - CDP1802
-
Just say no to Entity Framework.
".45 ACP - because shooting twice is just silly" - JSOP, 2010
-----
You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
-----
When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013well said
-
I guess you should mix it, as already commented, to push out prototypes and quick showcases it's fine to go code-first. For most other stuff i'd suggest DB first. I for my self went up with all basic data i need for the application, built up the database and stuff and then coded. But for new small things that just need a new table or field i mostly design it in code first, show it, get the changes fixed and then put it in the DB before i code the final implementation.
if(!string.IsNullOrWhiteSpace(_signature))
{
MessageBox.Show("This is my signature: " + Environment.NewLine + _signature);
}
else
{
MessageBox.Show("404-Signature not found");
}I usually work with dbs. So The db is already included in the virgin app/server code as a basic entity. I also use the db for logging. so its just natural. It is just a part of the system. As per the remote hardware etc.