ADO.NET Entity Framework · Programming with Entity SQL The EntityClient provides the usual...

19
ADO.NET Entity Framework Mike Taulty Developer & Platform Group Microsoft Ltd [email protected] http://www.mtaulty.com

Transcript of ADO.NET Entity Framework · Programming with Entity SQL The EntityClient provides the usual...

Page 1: ADO.NET Entity Framework · Programming with Entity SQL The EntityClient provides the usual Connection, Command, DataReader There is no EntityDataAdapter V1.0 the model is read-only

ADO.NET Entity Framework

Mike TaultyDeveloper & Platform GroupMicrosoft [email protected]://www.mtaulty.com

Page 2: ADO.NET Entity Framework · Programming with Entity SQL The EntityClient provides the usual Connection, Command, DataReader There is no EntityDataAdapter V1.0 the model is read-only

ADO.NET Entity Framework

Extension to the ADO.NET provider model

FunctionalityProgram against an abstracted model of your store schema

Use traditional ADO.NET API or ORM/LINQ

Slated to ship mid 2008Currently at Beta 3, Tooling at CTP 2

Downloadable in ASP.NET 3.5 Extensions Preview

Page 3: ADO.NET Entity Framework · Programming with Entity SQL The EntityClient provides the usual Connection, Command, DataReader There is no EntityDataAdapter V1.0 the model is read-only

Quick Demo to Defer Boredom

Page 4: ADO.NET Entity Framework · Programming with Entity SQL The EntityClient provides the usual Connection, Command, DataReader There is no EntityDataAdapter V1.0 the model is read-only

.NET Entity Provider (Entity SQL)

Command

ConnectionReader

V3.0

Entity Framework Architecture

Store

.NET Data Provider

V2.0

Command

ConnectionReader

Adapter

V3.0

Conceptual Model

Entity Entityrelationship

Mapping (MSL)

V3.0Programming Model

Object Relational Mapping

LINQ

Page 5: ADO.NET Entity Framework · Programming with Entity SQL The EntityClient provides the usual Connection, Command, DataReader There is no EntityDataAdapter V1.0 the model is read-only

Tools, SSDL, MSL, CSDL

Page 6: ADO.NET Entity Framework · Programming with Entity SQL The EntityClient provides the usual Connection, Command, DataReader There is no EntityDataAdapter V1.0 the model is read-only

Programming with Entity SQL

The EntityClient provides the usual

Connection, Command, DataReader

There is no EntityDataAdapter

V1.0 the model is read-only

Entity SQL has some additional constructs to expose the underlying conceptual model – e.g.;

ANYELEMENT CREATEREF DEREF IS OF KEY MULTISET NAVIGATE OFTYPE

OVERLAPS REF ROW SELECT SET TREAT USING

Page 7: ADO.NET Entity Framework · Programming with Entity SQL The EntityClient provides the usual Connection, Command, DataReader There is no EntityDataAdapter V1.0 the model is read-only

Programming with Entity Client

Page 8: ADO.NET Entity Framework · Programming with Entity SQL The EntityClient provides the usual Connection, Command, DataReader There is no EntityDataAdapter V1.0 the model is read-only

Mapping Examples ( 1 – Splitting )

Store

Good Customers

ID

FirstName

LastName

Bad Customers

ID

ForeName

Surname

Customers

CustomerId

First

Last

Type

EntitiesMapping

Type=“G”

Type=“B”

Page 9: ADO.NET Entity Framework · Programming with Entity SQL The EntityClient provides the usual Connection, Command, DataReader There is no EntityDataAdapter V1.0 the model is read-only

Mapping Examples ( 2 – TPH )

Store

Customer

CustomerId

First

Last

EntitiesMapping

Customers

ID

FirstName

LastName

IsPremium

Overdraft

AccountManagerPremiumCustomer

Overdraft

AccountManager

?

* Framework also supports TPT

Page 10: ADO.NET Entity Framework · Programming with Entity SQL The EntityClient provides the usual Connection, Command, DataReader There is no EntityDataAdapter V1.0 the model is read-only

Mapping Examples ( 3 – View + SPs )

Store

UkCustomer

CustomerId

Name

EntitiesMapping

ClientView1

select c.id, c.name

from customers c

where c.country = ‘UK’

p_DeleteUkCustomer

p_UpdateUkCustomer

p_InsertUkCustomer

Page 11: ADO.NET Entity Framework · Programming with Entity SQL The EntityClient provides the usual Connection, Command, DataReader There is no EntityDataAdapter V1.0 the model is read-only

Querying with Entity SQL

Page 12: ADO.NET Entity Framework · Programming with Entity SQL The EntityClient provides the usual Connection, Command, DataReader There is no EntityDataAdapter V1.0 the model is read-only

Programming with LINQ to Entities

New Data Access ORM API implemented in assembly

System.Data.Entity.dll

System.Data.Entity.Design.dll

Many NamespacesSystem.Data.Entity

System.Data.Objects

and many more...

ORM API can be used with or without LINQ

Page 13: ADO.NET Entity Framework · Programming with Entity SQL The EntityClient provides the usual Connection, Command, DataReader There is no EntityDataAdapter V1.0 the model is read-only

Key Classes

StateManagement

Connection

provider

Metadata

MSL SSDLCSDL

CRUD

Page 14: ADO.NET Entity Framework · Programming with Entity SQL The EntityClient provides the usual Connection, Command, DataReader There is no EntityDataAdapter V1.0 the model is read-only

LINQ to Entities – Possible Topics

Change Tracking

Concurrency Transactions (i)POCO

Stored

ProcsInheritance

Customising Code-Gen

Metadata

N-TierCompiled Queries

Page 15: ADO.NET Entity Framework · Programming with Entity SQL The EntityClient provides the usual Connection, Command, DataReader There is no EntityDataAdapter V1.0 the model is read-only

LINQ to Entities

Page 16: ADO.NET Entity Framework · Programming with Entity SQL The EntityClient provides the usual Connection, Command, DataReader There is no EntityDataAdapter V1.0 the model is read-only

Resources

Download ASP.NET 3.5 Extensions Preview

http://www.asp.net

ADO.NET Team Blog

http://blogs.msdn.com/adonet

Search for “entity” on

http://mtaulty.com

Page 17: ADO.NET Entity Framework · Programming with Entity SQL The EntityClient provides the usual Connection, Command, DataReader There is no EntityDataAdapter V1.0 the model is read-only

Updates

Go here to download the latest version of this slide-deck

http://mtaulty.com/downloads/dw08.zip

Page 18: ADO.NET Entity Framework · Programming with Entity SQL The EntityClient provides the usual Connection, Command, DataReader There is no EntityDataAdapter V1.0 the model is read-only

MSDN in the UK

Visit http://msdn.co.ukNewsletter

Events

Screencasts

Blogs

Page 19: ADO.NET Entity Framework · Programming with Entity SQL The EntityClient provides the usual Connection, Command, DataReader There is no EntityDataAdapter V1.0 the model is read-only

© 2007 Microsoft Ltd. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.

The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market

conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation.

MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.