none
what scenario using code first or entity framework RRS feed

  • Question

  • I need to build web site by .net web technology asp.net mvc USING C#

    But i confuse  

    What is best for build Web site Implementation by MVC

    Using Entity framework(build database and create modules automatic by EF)

    OR

    Implementing web site by using Code First ?

    Saturday, January 14, 2017 2:24 AM

All replies

  • Hi,

    In my opinion, Entity Framework is an object-relational mapping (ORM) tool for developer, it provides three approaches to create models .

    Model First: You can define your model using boxes and lines and then generate a database.

    In this approach,  the Entity Framework offers a designer that can create a conceptual data model, and automatically creates an .edmx file to store the model and mapping information and map the database schema to the database. 

    Database First: You can create a boxes and lines model that maps to an existing database.

    This approach means that you have already a database and you create a model from an existing database. It generates models based on the tables and columns in a relational database. It also automatically creates an .edmx file to store the model and mapping information.

    Code First: You can define your models in code and then generate a database or an existing database.

    In Code First, you can not only create models from a new database, you can also create models form an existing database. Whether you have an existing database or not, you can code your own classes and properties that correspond to tables and columns without an .edmx file, and it would generate the database schema dynamically at runtime.

    The three methods that can be applied to different scenarios and methods chosen for your project requirements is essential.

    For example, if your development is based on original database , then just Database First, if it is a new project, you can Code First. From the development of the Entity Framework, Code First and be placed in an important position. Code First don't automatically creates .edmx file which is not uncontrollable, you have more customization options and more control.

    Please refer a good summary about difference between the three approach, Code-first vs Model/Database-first

    Best Regards,

    Bob


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, January 16, 2017 5:17 AM