Hello and welcome everybody to our TNWiki Article Spotlight on Tuesday.
Last time I wrote an Article Spotlight blog post, it was about an important technology which allows developers to have a class-oriented data access, namely the famous ORM Entity Framework.
Today, with the second part of the series, we'll go a little bit deeper into considering the Code-First approach.
From the article:
Having evaluated the practical approach Database-First, one wonders what are the reasons that should lead us to the Code-First paradigm. On the other hand, you could design the database, working directly on SQL Server (for example) our scheme, entities, keys and relationships, then delegating the practical Database-First derivation of classes and their interconnections, however, taking advantage of the GUI that EDMX models provide. In fact, there are several reasons why Code-First may be an appropriate choice. First, it proves to be the only feasible in the case in which the base data does not exist, but must be created by the application. In this case, the classes will be defined by the developer to represent the template on which to create the database and its entities. Code-First is optimally interface with existing databases: in addition, where the basic data should be accessible only in part (eg .: interests us derive not complete tables), Code-First allows the declaration of classes that contain only what we actually need. We have more control on the same database structure, which will be determined by the written code. If you need to apply changes to the database, we will have useful migration tools, redistributable with the application. Moreover, - and in part here we repeat - the code in use is actually the one written, avoiding the over-bloating that the Database-First approach, by its inherent structure, in a certain sense imposes, with its numerous files and the total derivation of the referenced tables. Recall also that - although the present article deals with EF 6.1.3 - from version 7.0 Code-First becomes the only usable paradigm, and therefore know as of now involves a major advantage for the future.
The article can be found here: Entity Framework Introduction using C#, part II - Code-First and Migrations
The original version of the article is in Italian, and can be found here: Introduzione ad Entity Framework con C#, parte II: Code-First e Migrazioni (it-IT)
Hope you liked it, and that it will be of use for your studies and work.