Upload
microsoft-developer-network-msdn-belgium-and-luxembourg
View
928
Download
3
Tags:
Embed Size (px)
DESCRIPTION
More info on Techdays.be
Citation preview
Data centric apps for Web, desktop and mobile with Entity Framework 5Diego VegaDeveloper Lead Microsoft
Data Centric Apps with EF5 | Agenda
Brief EF overvie
w
What is new in
EF5Demos Post
EF5
EF Overview | What is EF?
Microsoft’s Object/Relational Mapper
• Recommended technology to connect .NET applications to databases
• LINQ against disparate relational databases
Product goals• Make .NET & Windows Azure the best
platform for data centered apps• Be the most productive data access API
Existingdatabase
Newdatabase
Code-centricDesigner-centric
Database first• Reverse engineer into .edmx model• Classes auto-generated from .edmx
Model first• Create .edmx model in designer• Generate database from .edmx• Classes auto-generated from .edmx
Code first• Reverse engineer into code model• Requires EF PowerTools download
Code first• Define classes and mapping in code• Database auto-created at runtime
EF Overview | Developer Workflows
EF5 | How we ship it
EF NuGet Package• DbContext, Code First & Migrations• Included in VS 2012• Works with .NET 4.0 & 4.5, VS 2010 & 2012
EF Core bits in .NET• Updated in .NET 4.5• New features like Enums, Spatial, better performance, etc.
EF Designer in VS• Updated in VS 2012• New features like multiple diagrams, colorization, DbContext code generation, etc.
EF5 | Major new features
Both for code-centric and designer-centric developers• Enum support• Spatial data types• Auto-compiled query• Parameter evaluation performance
Only for designer-centric developers• Table-valued Functions (TVFs)• Multiple diagrams and coloring• Batch import of stored procedures• DbContext code generation
Demo:Park Finder
Demo: Park Finder
Search Text
Coordinates
List<Park>
MapGridVie
w
Bing Maps API
ParkFinder Web API
SQL Server
Entity Framework
EF5 | Performance ImprovementsInline LINQ query
return db.People.First(e => e.Id == id);
CompiledQuery
private static readonly Func<MyContext, int, Person> findPerson = CompiledQuery.Compile((MyContext db, int id) => db.People.First(e => e.Id == id)); …
return findPerson(id);
EF5 | Performance Improvements
// Micro-benchmark: repeated execution of a query by keyusing (var db = new MyContext()){ for(int id = 0; id < 5000; id++) { db.People.First(e => e.Id == id); }}
EF5 | Query by key benchmark results
Handcoded ADO.NET
EF Raw SQL EF Compiled Query Entity SQL LINQ to Entities LINQ to SQL
.NET 4.0 1 1.98519163763066 2.62108013937282 15.1811846689895 23.140243902439 16.4965156794425
.NET 4.5 1 2.10754414125201 2.69101123595506 4.06340288924559 4.11637239165329 13.5040128410915
250%
750%
1250%
1750%
2250%
Tim
e s
pent
8/8/2011 8/15/2011 8/22/2011 8/29/2011 9/5/2011 9/12/2011 9/19/20110
25
50
75
100
125
Auto-compiled queries
Parameter eval-uation optimiza-
tion
Avera
ge R
ow
s P
er
Seco
nd
EF5 | Web end-to-end benchmark
Runs on .NET 4.5 up to 67% faster than on .NET 4.0!
EF6 | Go to my EF6 talk for more!Open source with contributionsCode under Apache 2.0 licenseTargeting mid-2013 RTMMicrosoft license, branding, quality and support
Major new features Async query & save Enums, spatial, etc. on .NET 4.0 Code-based configuration Connection resiliency (retries) DbContext connection and
transaction improvements Code First
Custom conventions CUD stored procedure support
Tooling consolidation
EF | Resources
Vote ef.mswish.net
Learn msdn.com/data/ef
Contribute entityframework.codeplex.com
Follow @efmagicunicorns @divega facebook.com/efmagicunicorns blogs.msdn.com/adonet blogs.msdn.com/diego