This document summarizes a presentation about Entity Framework 5 (EF5) and the future of EF6. It introduces EF as Microsoft's object-relational mapper for .NET applications, outlines major new features in EF5 like enum support and performance improvements, and demonstrates EF code and tools. It also briefly previews additional features planned for the open source EF6, including async queries and connection resiliency.
Cloud enable your Windows Store Apps with Mobile Services
Building data centric applications for web, desktop and mobile with Entity Framework 5
1. Data centric apps for Web, desktop
and mobile with Entity Framework 5
Diego Vega
Developer Lead
Microsoft
2. Data Centric Apps with EF5 | Agenda
What is
Brief EF
new in Demos Post EF5
overview
EF5
3. EF Overview | What is EF?
• Recommended technology to connect .NET Microsoft’s
applications to databases Object/Relational
• LINQ against disparate relational databases Mapper
• Make .NET & Windows Azure the best platform for
data centered apps Product goals
• Be the most productive data access API
4. EF Overview | Developer Workflows
Designer-centric Code-centric
Model first Code first
New • Create .edmx model in designer • Define classes and mapping in code
database • Generate database from .edmx • Database auto-created at runtime
• Classes auto-generated from .edmx
Database first Code first
Existing • Reverse engineer into .edmx model • Reverse engineer into code model
database
• Classes auto-generated from .edmx • Requires EF PowerTools download
5. 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.
6. 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
10. EF5 | Performance Improvements
// Micro-benchmark: repeated execution of a query by key
using (var db = new MyContext())
{
for(int id = 0; id < 5000; id++)
{
db.People.First(e => e.Id == id);
}
}
11. EF5 | Query by key benchmark
results
2500%
2000%
Time spent
1500%
1000%
500%
0%
HANDCODED EF RAW SQL EF COMPILED ENTITY SQL LINQ TO LINQ TO SQL
ADO.NET QUERY ENTITIES
Handcoded ADO.NET EF Raw SQL EF Compiled Query Entity SQL LINQ to Entities LINQ to SQL
.NET 4.0 100% 199% 262% 1518% 2314% 1650%
.NET 4.5 100% 211% 269% 406% 412% 1350%
12. EF5 | Web end-to-end benchmark
125
Runs on .NET 4.5 up to 67% faster than on .NET 4.0!
100
Average Rows Per Second
Parameter
evaluation optimization
75
Auto-compiled queries
50
25
0
8/8/2011 8/15/2011 8/22/2011 8/29/2011 9/5/2011 9/12/2011 9/19/2011
13. EF6 | Go to my EF6 talk for more!
Open source with contributions Major new features
Code under Apache 2.0 license Async query & save
Targeting mid-2013 RTM Enums, spatial, etc. on .NET 4.0
Code-based configuration
Microsoft
Connection resiliency (retries)
license, branding, quality and
DbContext connection and
support transaction improvements
Code First
Custom conventions
CUD stored procedure support
Tooling consolidation