Presentation is loading. Please wait.

Presentation is loading. Please wait.

C# kursus Rohde & Schwarz1 Object Relational Mapping – ORM Entity Framework.

Similar presentations


Presentation on theme: "C# kursus Rohde & Schwarz1 Object Relational Mapping – ORM Entity Framework."— Presentation transcript:

1 C# kursus Rohde & Schwarz1 Object Relational Mapping – ORM Entity Framework

2 ORM? 2C# kursus Rohde & Schwarz

3 Objects vs. Relations C# kursus Rohde & Schwarz3

4 Object-Relational Impedance Mismatch Object-OrientedRelational C# kursus Rohde & Schwarz4 Based on proven software engineering principles. Entry point is behaviour Object collections and associations derived from graph theory Based on proven mathematical principles. Entry point is data Data collections and associations derived from set theory

5 A Physical Data Model 5C# kursus Rohde & Schwarz

6 A Class Model 6C# kursus Rohde & Schwarz

7 Differences Physical Data ModelClass Model C# kursus Rohde & Schwarz7

8 Benefits Of O/R Mapping C# kursus Rohde & Schwarz8 Clean OO design Hiding the relational model specifics lets the object model be more cleanly analyzed and applied. Productivity Simpler code as the object model is free from persistence constraints. Developers can navigate object hierarchies, etc. Separation of concerns and specialization Let the DB people worry about DB structure and the Object people worry about their OO models. Time savings The O/R mapping layer saves you from writing the code to persist and retrieve objects. O/R mapping tool vendors claim 20-30% reduction in the code that needs to be written. Writing less code also means less testing.

9 Drawbacks Of O/R Mapping C# kursus Rohde & Schwarz9 Usually commit the "Needless Repetition" deadly sin (a.k.a. DRY – "Don't Repeat Yourself“) The table structure as well as their relations are stored both in the DB and in the mapping files used by the O/R mapper Writing mapping files is a huge task Needs to be updated every time the database layout is changed Queries Limited query capabilities… … or performance problems on complicated queries Some O/R mappers implement caches, lazy initialization, batch modes etc. to help avoid the performance problems

10 ENTITY FRAMEWORK C# kursus Rohde & Schwarz10

11 Entity Framework What is Entity Framework? Entity Framework (EF) is an object-relational mapper that enables.NET developers to work with relational data using domain-specific objects. It eliminates the need for most of the data-access code that developers usually need to write. C# kursus Rohde & Schwarz11

12 Supported Databases MS SQL Server MySQL SQLite Oracle Firebird PostgreSQL... and more C# kursus Rohde & Schwarz12

13 Getting Started EF supports four development workflows: Find out which fits your conditions: C# kursus Rohde & Schwarz13

14 Installation Pre installed with Visual Studio 2012 Can be installed with NuGet in Visual Studio 2010 You might need to install NuGet first... C# kursus Rohde & Schwarz14

15 Using Entity Framework Create a mapping of your database Entity Data Model (Model First)Model First Database migrations not possible (yet) Plain Old CLR Objects (POCO) (Code First)Code First Database migrations possible C# kursus Rohde & Schwarz15

16 Using Entity Framework Connect through a sub class of DbContext Make queries using LINQ C# kursus Rohde & Schwarz16

17 Demo C# kursus Rohde & Schwarz17


Download ppt "C# kursus Rohde & Schwarz1 Object Relational Mapping – ORM Entity Framework."

Similar presentations


Ads by Google