What to select between these 2 approaches?
On what parameters we should take this decision?
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Prashant ShindePosted Jan 22, 2015, 8:07 AM
Manish Kumar ChoudharyPosted Jan 22, 2015, 7:04 AM
Code-first Vs Database-first
You are a database guy so the best approach for you is an incremental database-first approach where you define the stuff in DB (or VS Database tools) and update your model from the database. This will give you a big control over your database and allow you building the application and the DB incrementally. Why I think you will like it:- You did SQL DB Admin before - you probably know something about DB and how to design them for a performance - EF will not do anything from this for you. EF will not create indexes for you etc.
- 30-40 tables means that you will not build the model in one shoot. You will start with the small model and continuously grow it. Once you start making changes in DB or adding initialization data you will not want to lose these changes and the data. Code-first allows only deleting the whole database and recreating it from scratch. Model-first allow building the DB incrementally but you need Entity Designer Database Generation Power pack and VS 2010 Premium or Ultimate ($5.000-$10.000).
More about differences between DB first, Model first and Code first. Another answer describes differences between code-first and working with designer.Manish Kumar ChoudharyPosted Jan 22, 2015, 7:03 AM
CodeFirst cannot do anything that DB first cannot. At the end of the day they are both using the Entity Framework.
The main advantages of using codefirst are:
For more info see Code-first vs Model/Database-first and here Code-First or Database-First, how to choose?
Manish Kumar ChoudharyPosted Jan 22, 2015, 7:01 AM
Both are good it depends on your requirement only. No one can say one is good other is not.
I think the differences are:
Code first
Database first
Prashant ShindePosted Jan 22, 2015, 6:58 AM
Manish Kumar ChoudharyPosted Jan 22, 2015, 6:57 AM
If your database is ready then go to DB first approach it will create all the classes automatically
Manish Kumar ChoudharyPosted Jan 22, 2015, 6:55 AM
If you are new in EF then I will recommend DB first approach. It will easy and simple to use without much configuration. Anyone start to learn FE they should go with EF after having clear idea about that you can go with code first approach so it will be easier.
Prashant ShindePosted Jan 22, 2015, 6:54 AM
Prashant ShindePosted Jan 22, 2015, 6:52 AM
Manish Kumar ChoudharyPosted Jan 22, 2015, 6:45 AM
It depends on your requirement if you want full control through c# code then use code first approach otherwise DB first.