locked
Newbie Query about Entity Framework RRS feed

  • Question

  • i never work with  Entity Framework but i heard the term called database first, model first, code first. can anyone tell me what it is all about?

    what is the meaning of database first ?

    what is the meaning of code first ?

    what is the meaning of model first ?

    also guide with few article which will discuss all above in depth. help me to understand & work with database first, model first, code first approach for beginner.

    for long time i am working with MS data application block and i am happy with it but now there is so much hype for EF in market. so i have one another question that EF is really much better than MS data application block. i need comparison between  MS data application block & EF. EF would be right choice for big database where huge data enter every day ? EF performance is good when thousand of user access database data & perform CRUD action ?

    i am looking for a expert comment for EF performance. tell me when one should use EF as data access layer.

    thanks


    Wednesday, May 22, 2013 8:12 AM

Answers

  • Hi,

    basically EF is an object relational mapper. i.e., object in your .NET app will be mapped to some relation(table) in database so that insteed of writing raw sql over the database and coding lots of other access code, you just query over your local objects, mainly through LINQ.

    But if you go behind the scene, everything ultimately used ADO.NET Command and Reader objects that you were earlier using.

    There is nothing like performance will be better as compaired to other framework.

    The benefit you get is that you don't  need to write raw sql, don't need to go over database because every relation comes down to your end in the .NET project (in the .edmx designer).

    You can even directly call the Stored Procedure directly using EF. It is all about matter of ease and productivity for the developer and not necesserly about performance.

    Database first : generate model using the Database

    Code first : Generate model using code and then generate database from the model.

    MOdel first : generate the model in designer and then generate database from that model. You don't need to write any code in this case.

    Link provided by J Chase is the official home page of EF. So, I think that one is the best one.

    I hope this may help.


    One good question is equivalent to ten best answers.


    Wednesday, May 22, 2013 11:57 AM

All replies

  • The Data Developer Center has some good resources for getting started with EF, including this one on which approach to use.
    Wednesday, May 22, 2013 8:16 AM
  • Hi,

    basically EF is an object relational mapper. i.e., object in your .NET app will be mapped to some relation(table) in database so that insteed of writing raw sql over the database and coding lots of other access code, you just query over your local objects, mainly through LINQ.

    But if you go behind the scene, everything ultimately used ADO.NET Command and Reader objects that you were earlier using.

    There is nothing like performance will be better as compaired to other framework.

    The benefit you get is that you don't  need to write raw sql, don't need to go over database because every relation comes down to your end in the .NET project (in the .edmx designer).

    You can even directly call the Stored Procedure directly using EF. It is all about matter of ease and productivity for the developer and not necesserly about performance.

    Database first : generate model using the Database

    Code first : Generate model using code and then generate database from the model.

    MOdel first : generate the model in designer and then generate database from that model. You don't need to write any code in this case.

    Link provided by J Chase is the official home page of EF. So, I think that one is the best one.

    I hope this may help.


    One good question is equivalent to ten best answers.


    Wednesday, May 22, 2013 11:57 AM
  • can u redirect me to separate separate url for getting the knowledge .

    give me few good article links for Database first

    give me few good article links for Code first

    give me few good article links for Model first

    one u did not say if one need to use data access layer for a database where huge data is stored and also saving huge data every second then one should select EF or MS DAAB ?

    thanks

    Wednesday, May 22, 2013 2:49 PM
  • Hi Mou,

    You can find related documentation here:

    http://msdn.microsoft.com/en-us/data/ee712907

    Code First to a New Database
    Use Code First to define your model in code and then generate a database.

    Code First to an Existing Database
    Use Code First to create a code based model that maps to an existing database.

    EF Designer to a New Database (Model First)
    Use Model First to define your model using boxes and lines and then generate a database.

    EF Designer to an Existing Database (Database First)
    Use Database First to create a boxes and lines model that maps to an existing database.

    Best regards,


    Chester Hong
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, May 28, 2013 10:42 PM