Entity Framework 4 - Tallan's Technology Blog - Tallan, Inc.

bracechumpInternet και Εφαρμογές Web

5 Φεβ 2013 (πριν από 3 χρόνια και 10 μήνες)

115 εμφανίσεις

building software to

help our clients grow

S
INCE

1985

www.tallan.com

Entity Framework 4 and WCF
Data Services 4

Max Weber
-

Senior Consultant


Get started with Entity Framework 4


Get started with WCF Data Services 4


Create website iBlog

3/18/2013

2

Tallan, Inc. Proprietary and Confidential. Copyright 2010.

Presentation Goals


Entity Data Model


Entity Framework 4


Open up Visual Studio


WCF Data Services 4


Open up Visual Studio


Summary / Questions


Cake


3/18/2013

Tallan, Inc. Proprietary and Confidential. Copyright 2010.

Presentation Agenda


Entity Data Model


The Entity Data Model (EDM) is a set of concepts that
describe the structure of data, regardless of its stored
form. The EDM borrows from the Entity
-
Relationship
Model described by Peter Chen in 1976, but it also
builds on the Entity
-
Relationship Model and extends its
traditional uses.


Extensions to E
-
R Model:


Separation of the entities and relationships from their
storage medium



http://msdn.microsoft.com/en
-
us/library/ee382825.aspx


3/18/2013

4

Tallan, Inc. Proprietary and Confidential. Copyright 2010.

What is the Entity Data Model?


Entity Type


entity key, inheritance, entity Sets, entity container


Association Type


foreign key, multiplicity, navigation properties,
association set, entity container


Property


Boolean, Int32, String


DateTime, Guid, Binary


Complex Types


3/18/2013

5

Tallan, Inc. Proprietary and Confidential. Copyright 2010.

Entity Data Model Key Concepts

Entity Framework Overview

Entity Framework Overview

3/18/2013

7

Tallan, Inc. Proprietary and Confidential. Copyright 2010.


Conceptual Model


Storage Model


Data Providers



3/18/2013

8

Tallan, Inc. Proprietary and Confidential. Copyright 2010.

Entity Framework 4


Conceptual schema definition language (CSDL)


Conceptual model == Domain model


.csdl file extension


CSDL is Entity Framework’s implementation of the
Entity Data Model


3/18/2013

9

Tallan, Inc. Proprietary and Confidential. Copyright 2010.

Conceptual Model


Entity Framework 4


Store schema definition language (SSDL)


Storage model == Logical model


Storage models are provider
-
specific


.ssdl file extension


3/18/2013

10

Tallan, Inc. Proprietary and Confidential. Copyright 2010.

Storage Model


Entity Framework 4


Mapping specification language (MSL)


Maps between conceptual and storage models


.msl file extension

3/18/2013

11

Tallan, Inc. Proprietary and Confidential. Copyright 2010.

Mapping Concepts to Storage


EF4


EF uses the ADO.NET Data Provider model


Providers


MS SQL Server


Indirect access to other DBs using ODBC, OLEDB


VistaDB


Devart


OpenLink Software


Synergy


…5+ more


ADO.NET Data Providers List


http://msdn.microsoft.com/en
-
us/data/dd363565.aspx



3/18/2013

12

Tallan, Inc. Proprietary and Confidential. Copyright 2010.

Providers


Entity Framework 4


Entity Data Model Wizard


ADO.NET Entity Data Model Designer


Update Model Wizard


Command line tool EDM Generator (EdmGen.exe)

3/18/2013

13

Tallan, Inc. Proprietary and Confidential. Copyright 2010.

Entity Data Model Tools


T4 Templates used to generate Entity classes from
CSDL


Entities based on EntitySet


Tied to .NET, System.Data


Plain Old CLR Objects (POCO)


Need POCO extension from Visual Studio Gallery


POCO Proxy


Extensions from Visual Studio Gallery


ADO.NET POCO Entity Generator


Tangible T4 Editor


3/18/2013

14

Tallan, Inc. Proprietary and Confidential. Copyright 2010.

Class Generation


Entity Framework

Code Time!


Entity Framework 4

3/18/2013

15

Tallan, Inc. Proprietary and Confidential. Copyright 2010.

Entity Framework: Recap

3/18/2013

16

Tallan, Inc. Proprietary and Confidential. Copyright 2010.


Formerly .NET Data Services (aka Astoria)


Description:


WCF Data Services enables creation and consumption
of data services for the Web or an intranet by using the
Open Data Protocol (OData).



WCF Data Services

Architecture Overview :

WCF Data Services


Exposes data as resources (URI)


http://localhost/Northwind.svc/Customers(‘ALFKI’)


http://localhost/Northwind.svc/Customers('ALFKI')/Orders
?$filter=Freight gt 50


3/18/2013

19

Tallan, Inc. Proprietary and Confidential. Copyright 2010.

RESTful work


WCF Data Services


Definition


OData enables you to expose your data as resources
that are addressable by URIs


Enables you to access and change data by using the
semantics of representational state transfer (REST)


Standard HTTP verbs supported:


GET, PUT, POST, DELETE.


Open Data Protocol (OData)

Reference: WCF Data Services Overview
-

http://msdn.microsoft.com/library/cc668794.aspx


Atom


JSON


XML

3/18/2013

21

Tallan, Inc. Proprietary and Confidential. Copyright 2010.

Output Formats


WCF Data Services


Entity Framework Provider


Uses Entity Data Models to structure access


Reflection Provider


Exposes data structures with interface IQueryable


Create/Update/Delete with interface IUpdatable


Custom Provider


Roll your own



Link to WCF Data Services Providers


http://msdn.microsoft.com/en
-
us/library/dd672591.aspx


3/18/2013

22

Tallan, Inc. Proprietary and Confidential. Copyright 2010.

Freedom of data source


WCF Data Services


Service Operators


Act at a service level


Interceptors


Act at an entity set level

3/18/2013

23

Tallan, Inc. Proprietary and Confidential. Copyright 2010.

Custom Business Logic


WCF Data Services


WCF Data Services Client Library


.NET Framework


Silverlight


OData SDK


Javascript (AJAX)


PHP


Java


Ruby


Windows Phone 7 (not yet released)


Objective
-
C (iPhone) (not yet released)


3/18/2013

24

Tallan, Inc. Proprietary and Confidential. Copyright 2010.

Client Libraries


WCF Data Services

Code Time!


WCF Data Services

3/18/2013

25

Tallan, Inc. Proprietary and Confidential. Copyright 2010.


OOTB IE Experience with WCF DS Atom feeds bad


Make this change to see Atom feeds properly:


Tools
-
> Internet Options
-
> Feeds and Web Slices
(Settings)


Uncheck “Turn on feed reading view”

3/18/2013

26

Tallan, Inc. Proprietary and Confidential. Copyright 2010.

WCF Data Services Atom feeds in IE

Recap:

WCF Data Services


Entity Data Model


Entity Framework 4


Conceptual Model


Storage Model


Class generation using T4 Templates


WCF Data Services 4


OData v2


RESTful services


Multiple Data Providers


Multiple Output formats



3/18/2013

28

Tallan, Inc. Proprietary and Confidential. Copyright 2010.

In Summary


This slide deck will be made available from the
following locations:


Tallan blogs
-

blogs.tallan.com


CTDOTNET


www.ctdotnet.org



Distribution of slide deck


Visual Studio Gallery


Visual Studio
-

Entity Framework 4.0 and WCF Data Services
4.0 in Visual Studio 2010


What's New and Cool in Entity Framework 4.0


DevelopMentor


ADO.NET Entity Framework


Entity Framework At
-
a
-
Glance


WCF Data Services


WCF Data Services Overview


WCF (ADO.NET) Data Services At
-
a
-
Glance


Data Development Videos


Programming Entity Framework


Don't Be Iffy (Julie
Lerman
)

Resources and Questions? Then Cake

It’s time for cake!

3/18/2013

31

Tallan, Inc. Proprietary and Confidential. Copyright 2010.