Entity Framework Development Approaches

As shown in the following diagram, there are three ways you can work with data in the Entity Framework: Database First, Model First, and Code First.
Development_approaches_diagram

Database First

If you already have a database, the Entity Framework can automatically generate a data model that consists of classes and properties that correspond to existing database objects such as tables and columns. The information about your database structure (store schema), your data model (conceptual model), and the mapping between them is stored in XML in an .edmx file. Visual Studio provides the Entity Framework designer, which is a graphical designer that you can use to display and edit the .edmx file. The sections Getting Started With the Entity Framework and Continuing With the Entity Framework in the Web Forms tutorial series use Database First development.

Model First

If you don't yet have a database, you can begin by creating a model using the Entity Framework designer in Visual Studio. When the model is finished, the designer can generate DDL (data definition language) statements to create the database. This approach also uses an .edmx file to store model and mapping information. The What's New in the Entity Framework 4 tutorial includes a brief example of Model First development.

Code First

Whether you have an existing database or not, you can code your own classes and properties that correspond to tables and columns and use them with the Entity Framework without an .edmx file. That's why you sometimes see this approach called code only, although the official name is Code First. The mapping between the store schema and the conceptual model represented by your code is handled by convention and by a special mapping API. If you don't yet have a database, the Entity Framework can automatically create the database for you, or drop and re-create it if the model changes. This tutorial series uses Code First development.
The data access API that was developed for Code First is based on the DbContext class. This API can also be used with the Database First and Model First development workflows. For more information, see When is Code First not code first? on the Entity Framework team blog.

POCO (Plain Old CLR Objects)

By default, when you use the Database First or Model First development approaches, the entity classes in your data model inherit from the EntityObject class, which provides them with Entity Framework functionality. This means that these classes technically aren't persistence ignorant and so don't conform fully to one of the requirements of domain-driven design. All development approaches of the Entity Framework can also work with POCO (plain old CLR objects) classes, which essentially means that they are persistence-ignorant because they don't inherit from the EntityObject class. In this tutorial you'll use POCO classes.

reference : http://www.asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/creating-an-entity-framework-data-model-for-an-asp-net-mvc-application

Comments

Popular posts from this blog

Data Flow Diagram (DFD)

VERIFIKASI SUARA MENGGUNAKAN METODE MFCC DAN DTW MENGGUNAKAN METODE MFCC DAN DTW (BAB II TINJAUAN PUSTAKA)

flexigrid + php with add and edit button