37
Data Development GPS: Guidance for Choosing the Right Data Access Technology for Your Application Today Shyam Pather ([email protected]) Development Manager Microsoft Corporation SESSION CODE: DEV324

Shyam Pather ([email protected]) Development Manager Microsoft Corporation SESSION CODE: DEV324

Embed Size (px)

Citation preview

Page 1: Shyam Pather (spather@microsoft.com) Development Manager Microsoft Corporation SESSION CODE: DEV324

Data Development GPS: Guidance for Choosing the Right Data Access Technology for Your Application Today

Shyam Pather ([email protected])Development ManagerMicrosoft Corporation

SESSION CODE: DEV324

Page 2: Shyam Pather (spather@microsoft.com) Development Manager Microsoft Corporation SESSION CODE: DEV324

AgendaData Access Technology Recap

ADO.NET Core Guidance

ADO.NET Entity Framework Guidance

WCF Data Services / OData Guidance

Page 3: Shyam Pather (spather@microsoft.com) Development Manager Microsoft Corporation SESSION CODE: DEV324

Data Access Technology Recap

Page 4: Shyam Pather (spather@microsoft.com) Development Manager Microsoft Corporation SESSION CODE: DEV324

Development of Native Data Access

SQL Server Databases

DB-Library ESQL for C

Various StoresVarious StoresVarious Stores …

API API

Raw Data

Native Client JDBC Drivers

ODBC AbstractCall-Level

OLE DB

ADO(RecordSet)

SimplifiedObject Level

(pointerlesslanguages)

MSDASQLRDO

1989-1992 Sept 1992 Aug 1995 Aug 1996 Oct 1996 2005-2008

Object Level(pointer-capable

languages)

DirectAPIs

PHP

Page 5: Shyam Pather (spather@microsoft.com) Development Manager Microsoft Corporation SESSION CODE: DEV324

Native Data Access GuidanceNo need to rewrite for the sake of rewriting

“If it’s not broken, don’t fix it”

ODBC is the primary native API going forwardMost efficient, full-featured API for SQL ServerBest support for multiple data sources (more drivers for ODBC than any other technology)

ADOUsed mainly in scripting and ASP classicFully supported, but no new feature work – only gets supportability and security fixes

OLE DBUse it if you really want COM-based data accessMay be more awkward to use than other APIsODBC is likely a better choice

Page 6: Shyam Pather (spather@microsoft.com) Development Manager Microsoft Corporation SESSION CODE: DEV324

Development of .NET Data AccessObject-Relational

Mapping

LINQ to Entities

SQL Server DatabasesVarious Stores

Various Stores…

Raw Data

OLE DB ODBC

Data Providers

LINQ

AnyData

ADO.NET Core

ADO.NET Data Providers

LINQ to SQL, DataSet

.NET Classes

Entity Framework

Various Stores + XML

IQueryableIEnumerable

LIN

Q to

Obj

ects

, etc

.

LIN

Q to

XM

LEntity Data Model

LanguageIntegration

Pre-.NET Feb 2002 Nov 2007 Aug 2008

SqlClient

WCF Data Services(OData)

RESTfulServices

Page 7: Shyam Pather (spather@microsoft.com) Development Manager Microsoft Corporation SESSION CODE: DEV324

.NET Data Access Guidance (Overview)ADO.NET Core

Use it when you want the lowest level controlIt’s the basis for everything new in the .NET data access world

LINQ to SQLFully supported but little new investment

ADO.NET Entity FrameworkSignificant investment in .NET 4 and beyondAll new apps should start hereExisting apps can leverage EF incrementally

WCF Data Services and ODataUse it for services that primarily expose dataGrowing ecosystem of clients and servers

Page 8: Shyam Pather (spather@microsoft.com) Development Manager Microsoft Corporation SESSION CODE: DEV324

ADO.NET Core Guidance

Page 9: Shyam Pather (spather@microsoft.com) Development Manager Microsoft Corporation SESSION CODE: DEV324

ADO.NET Core in Context

ADO.NET Core still provides the most controlAnd the most familiar patterns for developers

DataSets aren’t going awayThough EF is a better choice for many new apps

ADO.NET Core is the foundation of the Entity FrameworkProvider layerIncremental evolution for apps from ADO.NET Core to EF

Page 10: Shyam Pather (spather@microsoft.com) Development Manager Microsoft Corporation SESSION CODE: DEV324

ADO.NET Core Recommendations

Where should data access code go?

Guidance is more about patterns than features

Modern app patterns can be used with ADO.NET core

Separation of concerns is important!Hide your data access code behind a repositoryUse simple POCOs to represent your data

ControllerAction

Methods

ViewHTML

ModelRepository +

POCOs

Page 11: Shyam Pather (spather@microsoft.com) Development Manager Microsoft Corporation SESSION CODE: DEV324

ADO.NET Core Guidance

DEMO

Page 12: Shyam Pather (spather@microsoft.com) Development Manager Microsoft Corporation SESSION CODE: DEV324

ADO.NET Entity Framework Guidance

Page 13: Shyam Pather (spather@microsoft.com) Development Manager Microsoft Corporation SESSION CODE: DEV324

Entity Framework in ContextEF is the O/RM in the .NET Framework

EF in .NET 3.5 SP1 --> EF 3.5EF in .NET 4 --> EF 4

EF is based on the EDMModeling is a big bet for Microsoft

We listened to the customer feedback on EF 3.5There was a lot of it

We made significant improvements in EF 4Feedback has been overwhelmingly positive

Page 14: Shyam Pather (spather@microsoft.com) Development Manager Microsoft Corporation SESSION CODE: DEV324

Entity Framework Customer Feedback

Photo Credit: Jim Wooley

Page 15: Shyam Pather (spather@microsoft.com) Development Manager Microsoft Corporation SESSION CODE: DEV324

New in Entity Framework 4.0Model-first developmentAutomatic pluralizationForeign keys in modelsPOCO class supportLazy loadingT4 Code GenerationTemplate customizationIObjectSetVirtual SaveChangesObjectStateManager control

Self-tracking entitiesSQL generation improvementsMore LINQ operator supportLINQ extensibilityExecuteStoreQueryExecuteStoreCommandSPROC import improvementsModel defined functionsWPF designer integrationCode-Only development (Feature CTP)

See all these in action in DEV205: Overview of the Microsoft ADO.NET Entity FrameworkWednesday, June 9 | 1:30 PM – 2:45 PM | Auditorium B

Page 16: Shyam Pather (spather@microsoft.com) Development Manager Microsoft Corporation SESSION CODE: DEV324

Guidance on Creating ModelsStart with the database …

… and then generate the model + codeWhy? It already exists, or you want low level control over the databaseWhat? Import model into edmx and tweakWalkthrough: This talk

Start with an edmx model …… and then generate the database + codeWhy? You want separation from code and database in a declarative formatWhat? Create a model in the designerWalkthrough: http://bit.ly/cBueMh

Start with .net classes …… and then generate the database + modelWhy? Primarily focused on code shape, database is an implementation detailWhat? Define classes in code, adjust shape using contextbuilderWalkthrough: http://bit.ly/NBI9H

Page 17: Shyam Pather (spather@microsoft.com) Development Manager Microsoft Corporation SESSION CODE: DEV324

EF RecommendationsStart with the EF for new apps

Use Patterns – adopting an O/RM sets you up well for this

Repository, Unit of WorkPOCO / “Persistence Ignorant” classesDDD/TDD

Learn about the EF features and techniques you can use to tune your applications

Compiled queriesSplitting up models…

Learn more at DEV305Deep Dive into Microsoft

ADO.NET Entity Framework Thursday

1:30 – 2:45 PM Auditorium A

Page 18: Shyam Pather (spather@microsoft.com) Development Manager Microsoft Corporation SESSION CODE: DEV324

ADO.NET Entity Framework Guidance

DEMO

Page 19: Shyam Pather (spather@microsoft.com) Development Manager Microsoft Corporation SESSION CODE: DEV324

Data Services Guidance

Page 20: Shyam Pather (spather@microsoft.com) Development Manager Microsoft Corporation SESSION CODE: DEV324

Naming Confusion

ADO.NET Data ServicesUsed up to 3.5 SP1 Update for Data Services and in VS 2008

WCF Data ServicesUsed in .NET 4 / VS2010 and futureFirst step in alignment with WCF stack

Open Data Protocol (OData)The protocol used by WCF Data Services

Page 21: Shyam Pather (spather@microsoft.com) Development Manager Microsoft Corporation SESSION CODE: DEV324

Data Services in Context

What is WCF Data Services?Server framework for creating REST-based data-centric web servicesClient libraries for consuming data servicesREST-based protocol called OData (Open Data Protocol)

It’s part of the WCF stack

The OData ecosystem is growing!Big announcement at MIX10

Page 22: Shyam Pather (spather@microsoft.com) Development Manager Microsoft Corporation SESSION CODE: DEV324

Releases

First shipped (v1) in .NET 3.5 SP1Update for .NET 3.5 SP1

Release is now live for downloadEnables SharePoint lists as OData feeds in the next version of SharePoint

SL3 CTPUpdated client for talking to the 3.5 SP1 update

.NET 4All features from 3.5 SP1 update release Internal changes to support POCO, FKs, etc. as introduced by EF4

SL 4All features from SL3 CTPSupports NTLM & Basic auth out of the browser and xDomain

Page 23: Shyam Pather (spather@microsoft.com) Development Manager Microsoft Corporation SESSION CODE: DEV324

Scenarios for Data Services

•Client-server designed and deployed together

•Functionality surfaces in user interface

DLL + XAML

Data (XML, etc)

Data in Modern Web Apps Online Services

•Loosely coupled clients and servers

•State, functionality through service interface

Data (XML, etc)

Page 24: Shyam Pather (spather@microsoft.com) Development Manager Microsoft Corporation SESSION CODE: DEV324

What is OData?Uniform way of representing structured data

Atom, JSON formats

Uniform URL conventionsNavigation, filtering, sorting, paging, etc.

Uniform operationsAddressabilityGET, POST, PUT, DELETE always mean the same

A growing number of services and clientsServers: OGDI, NetFlix, Reporting ServicesClients: .NET, AJAX, PHP, Excel

Page 25: Shyam Pather (spather@microsoft.com) Development Manager Microsoft Corporation SESSION CODE: DEV324

OData Producers and Consumers

Servers• WCF Data Services• SharePoint 2010• SQL Server Reporting Services 2008 R2• SQL Azure• IBM WebSphere eXtreme Scale• Microsoft Media Room• WCF RIA Services

Services• Netflix• Mix 2010• Nerd Dinner• Vancouver’s vanGuide• Open Government Data Initiative• Open Science Data Initiative• Microsoft Codename “Dallas”• City of Edmonton

Clients• Excel + PowerPivot• LINQPad• OData Explorer

Client libraries• .NET• Silverlight• Windows Phone 7 Series• Javascript• Java• Objective-C• PHP

http://odata.org/producers

http://odata.org/consumers

Page 26: Shyam Pather (spather@microsoft.com) Development Manager Microsoft Corporation SESSION CODE: DEV324

OData Talks You Should See

Tech Ed SessionsDEV208: Open Data for the Open Web – Tuesday | 5:00 – 6:15 PM | Rm 279DEV303: Building RESTful Applications with the Open Data Protocol – Wednesday | 3:15 – 4:30 PM | Rm 283DEV323: Best Practices: Creating OData Services Using WCF Data Services – Wednesday | 5:00 – 6:15 PM | Rm 295ARC306: Open Data for the Enterprise – Thursday | 8:00 – 9:15 AM | Rm 288

MIX RecordingsOData: There’s a feed for that - http://live.visitmix.com/MIX10/Sessions/FT12Implementing OData: How to create a feed for that - http://live.visitmix.com/MIX10/Sessions/FT13

Page 27: Shyam Pather (spather@microsoft.com) Development Manager Microsoft Corporation SESSION CODE: DEV324

Data Services Recommendations

Use it when you are exposing a Data Model

Ways to implement a service(Easiest) Via EF over a relational databaseVia “Reflection Provider” over CLR objectsVia “DataServiceProvider” interfacesVia the spec

If you have data, think about exposing it as OData

Page 28: Shyam Pather (spather@microsoft.com) Development Manager Microsoft Corporation SESSION CODE: DEV324

Data Services Guidance

DEMO

Page 29: Shyam Pather (spather@microsoft.com) Development Manager Microsoft Corporation SESSION CODE: DEV324

Call To ActionExplore your data access options

Visit http://msdn.microsoft.com/data

Try out .NET 4 / VS2010http://msdn.microsoft.com/en-us/vstudio/default.aspx

Learn more about ODatahttp://odata.org/

Page 30: Shyam Pather (spather@microsoft.com) Development Manager Microsoft Corporation SESSION CODE: DEV324

Additional Resources and AnnouncementsMSDN Data Developer Center: http://msdn.com/data ADO.NET Team Blog: http://blogs.msdn.com/adonet OData Blog:http://odata.org/blog WCF Data Services Team Blog: http://blogs.msdn.com/astoriateam EF Design Blog: http://blogs.msdn.com/efdesign Data Platform Development Forums:http://msdn.com/data and click on the “Forums” tab

Come to the Data Development station in the DAT Track Area (yellow section of the TLC) to register for a Zune HD give-away!

Page 31: Shyam Pather (spather@microsoft.com) Development Manager Microsoft Corporation SESSION CODE: DEV324

Related ContentDEV208: Open Data for the Open Web – Tuesday | 5:00 – 6:15 PM | Rm 279DEV205: Overview of the Microsoft ADO.NET Entity Framework – Wednesday | 1:30 – 2:45 PM | Auditorium BDEV303: Building RESTful Applications with the Open Data Protocol – Wednesday | 3:15 – 4:30 PM | Rm 283DEV323: Best Practices: Creating OData Services Using WCF Data Services – Wednesday | 5:00 – 6:15 PM | Rm 295ARC306: Open Data for the Enterprise – Thursday | 8:00 – 9:15 AM | Rm 288DEV305: Deep Dive into Microsoft ADO.NET Entity Framework – Thursday | 1:30 – 2:45 PM | Auditorium A

BOF05-DV: Microsoft ADO.NET Entity Framework 4.0: What’s Your Take? – Thursday | 9:45-11:00 AM

DEV13-HOL: Building Applications and Services Using Open Data ProtocolDEV11-HOL: Using the Entity Framework in Microsoft .NET Framework 4.0 and Microsoft Visual Studio 2010

TLC-77: Microsoft SQL Server R2 Data Development (ADO.NET, OData, XML) – TLC Yellow

Page 32: Shyam Pather (spather@microsoft.com) Development Manager Microsoft Corporation SESSION CODE: DEV324

Track ResourcesVisual Studio – http://www.microsoft.com/visualstudio/en-us/Soma’s Blog – http://blogs.msdn.com/b/somasegar/ MSDN Data Developer Center – http://msdn.com/data ADO.NET Team Blog – http://blogs.msdn.com/adonet WCF Data Services Team Blog – http://blogs.msdn.com/astoriateam EF Design Blog – http://blogs.msdn.com/efdesign

Page 33: Shyam Pather (spather@microsoft.com) Development Manager Microsoft Corporation SESSION CODE: DEV324

Resources

www.microsoft.com/teched

Sessions On-Demand & Community Microsoft Certification & Training Resources

Resources for IT Professionals Resources for Developers

www.microsoft.com/learning

http://microsoft.com/technet http://microsoft.com/msdn

Learning

Page 34: Shyam Pather (spather@microsoft.com) Development Manager Microsoft Corporation SESSION CODE: DEV324

Complete an evaluation on CommNet and enter to win!

Page 35: Shyam Pather (spather@microsoft.com) Development Manager Microsoft Corporation SESSION CODE: DEV324

Sign up for Tech·Ed 2011 and save $500 starting June 8 – June 31st

http://northamerica.msteched.com/registration

You can also register at the

North America 2011 kiosk located at registrationJoin us in Atlanta next year

Page 36: Shyam Pather (spather@microsoft.com) Development Manager Microsoft Corporation SESSION CODE: DEV324

© 2010 Microsoft Corporation. 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.

Page 37: Shyam Pather (spather@microsoft.com) Development Manager Microsoft Corporation SESSION CODE: DEV324

JUNE 7-10, 2010 | NEW ORLEANS, LAJUNE 7-10, 2010 | NEW ORLEANS, LA