Presentation is loading. Please wait.

Presentation is loading. Please wait.

.NET Database Technologies:

Similar presentations


Presentation on theme: ".NET Database Technologies:"— Presentation transcript:

1 .NET Database Technologies:
Entity Framework additional notes – part 1

2 “Making the conceptual level real” (Blakeley, 2006)
Raises the level of abstraction from the logical (relational) level to the conceptual (entity) level Provides a data model that can define the structure essence of entities Entities and relationships as first-class objects Provides a concrete representation that allows us to manipulate data at this level Entity Data Model (EDM) – relates to Entity Relationship Model (Chen, 1976) The EDM is a value-based conceptual model - it does not incorporate behaviours of any kind Compare with UML, which expresses a conceptual model incorporating behaviour

3 Using an EDM EDM consists of:
Conceptual model Logical model (storage in relational database) Mapping between these EDM can be used to generate C# (or VB) classes which can be used in an application EF provides services for queries which work with C# objects EF manages mappings from database data to object properties

4 Benefits of using an EDM
Data model in application is not tied to database schema EDM allows developer to shape the data to suit the application, not the database Database may be a shared or legacy db which cannot be modified by application developer Normalisation or other optimisations in db may produce schema which does not match the application well Compare with Linq to SQL, which is (essentially) designed to allow strongly typed querying of relational database

5 So, it’s an ORM then? EF v1 allows building EDM by generating from database and manipulating in EDM Designer Allows building of EDM and configuring mapping to databases In both cases, EDM Designer generates code to represent data model in application Not intended to take existing domain model and map to relational database Not really an ORM, although it has many of the characteristics of one EF v4 moves significantly towards being an ORM

6 EF v1 and persistence ignorance
EF v1 entity classes require a number of non-PI features, including: Inherit from a certain base class - EntityObject Only instantiate via a provided factory Use specially provided datatypes, such as for collections - EntityCollection Not PI!

7 EDM Mappings - Basic Map entities directly to tables
EDM has navigation properties Can rename properties, exclude properties as required

8 EDM Mappings – Table Splitting
Two entities map onto the same table Entities have one-to-one relationship

9 EDM Mappings – Inheritance (Table per Hierarchy)
Base class and derived classes all map to the same table Discriminator field indicates which type to instantiate

10 EDM Mappings – Entity Splitting
One entity maps onto two separate tables Tables must share a common key Can access all properties in code without using navigation properties

11 EDM Mappings – Inheritance (Table per Type)
Base class and derived classes map to the separate tables Tables must share a common key

12 EDM Mappings – Complex Types
Refactor set of properties of an entity to a complex type Can use complex type in other entities Complex type can only be persisted as part of an entity


Download ppt ".NET Database Technologies:"

Similar presentations


Ads by Google