Thursday, April 7, 2011

.Net 4.1 Entity Framework 3 approach

Entity Framework allows the developers to write code against the domain classes for storing, retrieving and creating domain entities. .Net Entity Framework handles everything for you by generating all the data access code.



Entity Framework in .Net 4.0 provides multiple options of creating the data access code for a MVC Application.


1. Code-first, provides code-centric development workflow for creating the data access. The developer creates the domain class (and configures the database settings using CTP). The database and tables are created from the class and its public attributes.


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

Any change in the class or adding of an attribute, triggers the altering of the database entities automatically. (However, data may get deleted because of the database drop and recreation). There is option to stop the auto recreation of the database.

2. Model-First, model first workflow allows creating the domain model (Entity relationship diagram) in a designer.


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

Any change in the model by designer triggers the change in the data access code automatically for adding new attributes, and classes.


Any customization is done on the class extended from base data access code class. These custom classes are not recreated and our changes/customization are retained.


3. Database-First, allows starts with legacy database which creates the model thus generating the data access code of the models/domain.


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

Any change in the database triggers the changes in the model and hence in the data access code.

No comments:

Post a Comment