Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • .Net : Code first vs Database first approach

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 335
    Comment on it

    .Net : Code first vs Database first approach

     

    Code first


    In Code first approach Entity classes are declared and defined with properties. As soon as the .net code is compiled and run database is created automatically i.e database and tables will be created by Entity Framework based on entity classes defined.

     

    Advantages

    • Based on business objects database and tables are created.
    • Database Version Control which is good for small applications.

     

    Disadvantages

    • Database related code are also to be written in visual studio.
    • In order to work with stored procedure,stored procedure are mapped using Fluent API and stored procedure are written inside the code.
    • Update-database command is run from package manager console whenever changes in entity classes in code file is made to make changes in database tables. 
    • Data intensive application does not prefer code first approach.

     

    Database first

    In Database first approach database and table creation is done firstly. Based on this database and table creation entity data model classes are generated.

     

    Advantages

    • Data model classes are generated easily.
    • No writing of extra code for mapping,creation of keys and relationship as it is done on database and table creation.
    • It is good approach for Data intensive and large applications.

     

    Disadvantages

    • Generation of .edmx file from existing database result in generation of large pile of auto generated code due to code models associated with it.
    • Adding a functionality to data model means extension of model class. 

     

    The best appoach cannot be decided between the two as selection of approach between the two typically depends on applications which is being developed.

     

     

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: