Net harmony
1 / 24

.NET Harmony - PowerPoint PPT Presentation

  • Uploaded on

.NET Harmony. A look into efficiencies with EF Code First, Web API, & OData. Introduction. Travis Gosselin Senior Solutions Architect @ ToolBox Solutions Inc. 7 Years Development Experience in .NET Enjoy Working in the Full Stack of .NET

I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
Download Presentation

PowerPoint Slideshow about '.NET Harmony' - lela

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
Net harmony

.NET Harmony

A look into efficiencies with EF Code First, Web API, & OData


Travis Gosselin

Senior Solutions Architect @ ToolBox Solutions Inc.

7 Years Development Experience in .NET

Enjoy Working in the Full Stack of .NET

… but I do have a special place in my heart specifically for Web Development

Goals outline
Goals & Outline

  • .NET Harmony

  • Entity Framework

  • MVC 4


  • REST

  • OData

  • Entity Framework Code First


  • OData

  • Integration & Consumption

    *Focusing on concept introductions, with attention to integration & consumption.

Entity framework introduction
Entity Framework Introduction

  • Entity Framework is an ORM (Object Relational Mapper)

  • EF increases developer productivity by providing simple pre-generated data access components, accessible from a LINQ syntax.

Entity framework
Entity Framework

  • Open Source as of EF 5 (August 2012) – Current Version

  • Works with any relational database

  • Available Types:

    • Database First

    • Model First

    • Code First**

Entity framework code first
Entity Framework Code First

  • EF Code First was introduced in EF 4.1

  • Gets rid of the nasty EF Designer & the need for undesirable meta data and code generation only files (they may be POCO but they don’t quite cut it in EF DB First)

  • Convention Over Configuration (if you want)

  • Limitations:

    • Stored Procedure Support (available in EF6)

    • Enumeration Support (available in EF6)

Demo entity framework code first
DEMO: Entity Framework Code First

A Simple Music Database

Asp net web api

“ASP.NET Web API is a framework that makes it easy to build HTTP services that reach a broad range of clients, including browsers and mobile devices. ASP.NET Web API is an ideal platform for building RESTful applications on the .NET Framework” (

  • Simply: Building pure HTTP based endpoints without hassle

  • MVC4 (.NET 4.5) & Nuget Packages (*Available in ASP.NET Web Forms)

  • Take advantage of HTTP features

    • Uses HTTP verbs / actions by convention (or go custom)

    • Makes use of pure HTTP return codes

  • Content Negotiation (JSON, XML, & Custom)

  • Model binding & formatting

Why web api with svc asmx around
Why Web APIwith .SVC & .ASMX Around?

  • WCF Web API development turned into ASP.NET Web API

  • Provides pure HTTP endpoints for all application types (HTML5, mobile, desktop)

  • A conventional way for accessing data without WCF configurations & Contracts

  • Flexibility to create any type of web services:

    • RPC, CRUD, REST, OData

  • .SVC is still your choice on .NET 3.5 or you require SOAP based

  • Web API offers content negotiation

  • RPC vs REST? Am I doing it wrong if I’m not using REST?

Rest representational state transfer
REST = REpresentational State Transfer

  • URIs – can access all components via direct URI

  • Uniform Interface - GET (Retrieve), POST (Create), PUT (Update), DELETE (Delete)

  • Stateless – No state / context between requests.

  • Hypermedia (links) – allows expansion and navigation

  • Cache-ability – certain verb types define themselves as cacheable

    *REST is a style, SOAP is a protocol

Rest representational state transfer1
REST = REpresentational State Transfer


“ODatais a standardized protocol for creating and consuming data APIs. OData builds on core protocols like HTTP and commonly accepted methodologies like REST. The result is a uniform way to expose full-featured data APIs” (

  • Simply: Standardized method of accessing rich data APIs.

  • Open Microsoft Initiative

  • REST based

  • Provides metadata descriptions of entire API

  • Has its own OData querying syntax that gets used on the URI

Odata query syntax
OData Query Syntax




  •$filter=Name eq ‘Travis'

  •$filter=substringof(‘rav', Name)

Demo odata with web api
DEMO: OData with Web API

Wcf data services vs web api odata
WCF Data Services VS Web API OData

Web API OData

WCF Data Services

Was available here first

Most complete OData Support

Full Exposure of Data Stores without Business Logic

No immediate Content Negotiation

  • Limited OData support on launch

  • Simple integration with custom service layers & logic

  • Easy to use with non-LINQ provider data

  • Mix OData with other Service Types

  • Short release cycle on updates

  • Extensibility

  • Supports most important OData features

  • Does not easily support hypermedia linking

Demo further investigation into better odata in web api
DEMO: Further Investigation into better OData in Web API




Client integration with odata
Client Integration with OData

  • Use new HttpClient for Web API

    • What about WebClient in .NET 2.0? … HttpClient offers more flexibility to pure HTTP

    • WebClient is akin to ASMX as HttpClient is akin to Web API

  • JavaScript: Breeze, DataJS, JayData

  • .NET / Silverlight / Windows Phone / WinRT – WCF Data Services Client

  • iOS– OData4ObjC

  • Android – OData4j

Final thoughts
Final Thoughts

  • Things to investigate:

    • Web API Security will work with ASP.NET Authorization & Security

    • Web API Formatters & MediaTypeFormats Provide Ultimate Flexibility

    • Further investigation around the EntitySetController

  • Web API provides ultimate flexibility in most scenarios if you don’t require pure OData.

  • Simple straightforward exposure of OData from WCF Data Services if you have no business logic.

    • Thin slice your server code for JS Heavy SPAs by exposing your data store with OData

  • Web API conventions & simplicity are very attractive

Deck examples vs2012 2
Deck & Examples (VS2012.2)

  • Available at Blog:

  • Will be available soon on GitHub site.

  • Questions?