1. Entity Framework Today
Julie Lerman
The Data Farm
jlerman@thedatafarm.com
twitter @julielerman
Presented at Dotnet-zentral.ch
May 2, 2012
2. Julie Lerman
consultant/mentor
Microsoft MVP, INETA Speaker,
ASPInsider, MCP, VTdotNET Leader,
Pluralsight video author
contact
jlerman@theDataFarm.com
www.thedatafarm.com
blog
theDataFarm.com/blog
twitter
@julielerman
book web site
LearnEntityFramework.com
3. Plan A
• Entity Framework Overview
• “Getting Started” Code
• Focus on some features
• Non-”DemoWare” Solution
4. Object
Relational
Mapper
LINQ to Entities
Entity SQL
5. Entity Data Model
Runtime
EDMX EDM
(XML) System.Data.Metadata.Edm
.EntityType
.EdmProperty
.AssociationType
.EdmType
.Facet
Code + Code First
6. EF4.x EntityFramework.dll
Code First DbContext
Model-less EF Simpler Access
POCOPOCOPOCOPOCO Find, Local, Validation, etc…
Entity Framework 4
Visual Studio 2010
EDM Designer
“Core”
(in .NET 4)
(Object Services API (ObjectContext) & EntityClient API)
7. EF 5.x EntityFramework.dll
Code First DbContext
Model-less EF Simpler Access
POCOPOCOPOCOPOCO Find, Local, Validation, etc…
Entity Framework
Visual Studio 11
Core
EDM Designer
(in .NET 4.5)
(Object Services API (ObjectContext) & EntityClient API)
New: Enum support, Geo Data, auto query cache etc.
9. Getting Started
Pick your modeling workflow
DB First, Model First, Code First
Use DbContext for new projects
ObjectContext accessible if you need it
Database?
Existing or let Code First/Model First create it
Database or Model Changes
Model Updates & DB Updates (“migrations”) supported
Consider architecture
*Separate projects for model, context, etc *Repositories, UOW, automated tests, etc.
11. Feature Demos
More on migrations
No-tracking queries (performance)
Managing disconnected state
Data layer validations
My favorite small DbContext features
T4Scaffolding to gen context & repo
14. Testable
Classes
System.Data.Entity
Fake
Object/DbSet
Fake
Metadata &
Fake Context & DataA Object/DbContext
Context & Data B
Class
Class
Class
Repositories
Class
Repositories
Tests
Repositories
Repositories
Unit of Work
UI
16. Resources
• MSDN Developer Center: msdn.com/data/ef
• EF Team: blogs.msdn.com/adonet
• Rowan Miller Blog: romiller.com
• Arthur Vickers: blog.oneunicorn.com
• Julie Lerman: thedatafarm.com/blog
• LearnEntityFramework.com
• Pluralsight.com videos
• MSDN Magazine Data Points Column
– http://JulieL.me/datapointscolumn
17. Julie Lerman
consultant/mentor
Microsoft MVP, INETA Speaker,
ASPInsider, MCP, VTdotNET Leader
contact
jlerman@theDataFarm.com
www.thedatafarm.com
blog
theDataFarm.com/blog
twitter
@julielerman
book web site
LearnEntityFramework.com
18. Resources
• MSDN Developer Center: msdn.com/data/ef
• EF Team: blogs.msdn.com/adonet
• Rowan Miller Blog: romiller.com
• Arthur Vickers: blog.oneunicorn.com
• Julie Lerman: thedatafarm.com/blog
• LearnEntityFramework.com
• Pluralsight.com videos
• MSDN Magazine Data Points Column
– http://JulieL.me/datapointscolumn
19. Julie Lerman
consultant/mentor
Microsoft MVP, INETA Speaker,
ASPInsider, MCP, VTdotNET Leader
contact
jlerman@theDataFarm.com
www.thedatafarm.com
blog
theDataFarm.com/blog
twitter
@julielerman
book web site
LearnEntityFramework.com