Rowan Miller DEVB417 Setting expectations This is a level 400 session Assumes prior knowledge of data access and EF For getting started with EF httpbitlyEFTechEd2014 Agenda Where are we at ID: 559894
Download Presentation The PPT/PDF document "Entity Framework" is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.
Slide1Slide2
Entity Framework
Rowan Miller
DEV-B417Slide3
Setting expectations
This is a level 400 session
Assumes prior knowledge of data access and EF
For getting started with EF
http://bit.ly/EFTechEd2014Slide4
Agenda
Where are we at?
A quick look at EF6, EF6.1
and
EF6.1.1
Demos
EF6 in action
Where are we going?
What’s happening in EF7
Demos
EF7 sneak peekSlide5
Where are we at?Slide6
Versions
Entity Framework 3.5 SP1
Entity Framework 4
Entity Framework 4.1
Entity Framework 4.2
Entity Framework 4.3
Entity Framework 5
Entity Framework 6
Core runtime in .NET Framework
Newer runtime pieces out-of-band (
NuGet
)
Tooling
in Visual Studio
Runtime in .NET Framework
Tooling in Visual Studio
Runtime out-of-band (
NuGet
)
Tooling out-of-band (Microsoft Download Center)
Latest version “chained in” to new Visual Studio releases
Entity Framework
6.1
Entity Framework
6.1.1
Entity Framework 7Slide7
What
was new in EF6
From the EF Team
Asynchronous
query and save
Connection resiliency
Code-based configuration
Database command interception/logging
Custom Code First
conventions
Code First Insert, update, & delete stored procedures
Nested entity typesImproved transaction SupportMultiple contexts per databaseDbModelBuilder.HasDefaultSchemaConfigurable migrations history tableCreating context with an open connectionEnums, spatial and better performance on .NET 4.0Default transaction isolation level changed to READ_COMMITTED_SNAPSHOT
From our contributors
23 total contributionsCustom migrations operationsImproved warm up time for large modelsPluggable pluralization & singularization serviceDbModelBuilder.Configurations.AddFromAssembly
DbSet.AddRange/RemoveRangeSlide8
What was new in EF6.1
From the EF Team
120+ bug fixes
Tooling consolidation
Handling
Transaction.Commit
failures
[Index] attribute
Public mapping API
Configuring interceptors in web/
app.configImproved migrations change detection
Fewer database operations during startupFrom our contributors17 total contributionsSupport for String.Concat and .ToString in LINQ queries Support for enum
HasFlags in LINQ queriesEntity SQL canonical functions for SQL Server Compact Improved support for EF on MonoSlide9
What’s coming in EF6.1.1
From the EF Team
47
b
ug fixes (and counting)
From
our contributors
12 total contributions (and counting)
DbModelBuilder.Conventions.AddFromAssemblySlide10
Demos | EF6 in actionSlide11
Demo
Implementing soft deletes
Command tree
interceptors (EF 6
)
Custom Code First conventions (
EF 6)
Model annotations (EF 6.1)
Constructible
DbUpdateCommandTree
(EF 6.1.1)Slide12
dbo.Listings
ListingId
Title
Description
Price
IsDeleted
Listing
ListingId
Title Description
Price
IsDeleted
Custom Convention
public
class Listing{ public int ListingId { get
; set; } public string Title { get; set; } public
string Description { get; set; } public int Price { get; set;
}}
Model Builder
Query Pipeline
Database
var
query =
from
l in db.Listings orderby l.Title select l;
SELECT * FROM dbo.Listings
db.Listings.Remove
(listing);
db.SaveChanges
();
Update
Pipeline
Command Tree Interceptor
DELETE FROM
dbo.Listings
…
Command Tree Interceptor
WHERE
IsDeleted
= 0
[
SoftDelete
(
"
IsDeleted
"
)]
public
class
Listing
{
public
int
ListingId
{
get
;
set
; }
public
string
Title { get; set; } public string Description { get; set; } public int Price { get; set; } public bool IsDeleted { get; set; }}
SoftDeleteProperty
: "IsDeleted"
UPDATE
dbo.Listings
…
Soft DeletesSlide13
Demo
Full text search
Raw SQL queries (EF 4)
Custom
migration operations
(
EF 6
)
Public mapping API
(EF 6.1
)Slide14
Demo
Testing without hitting a database
Mockable
DbSet
<T> (EF 6)Slide15
Demo
Enabling logging with recompiling
Registering interceptors in
config
(
EF
6.1)
DatabaseLogger
(EF 6.1)Slide16
Demo
Tooling consolidationSlide17
Where are we going?Slide18
Entity Framework 7
EF6 supported
scenarios
Full .NET Framework (ASP.NET & traditional desktop applications)
Relational databases
EF7 enabling
new scenarios
New platforms (Windows Phone,
Windows
Store, etc.)
New data stores (Non-relational)Slide19
Challenges with current code base
Long
history going back to the WinFS days
Extensive use of older APIs and design patterns
Heavy use of APIs not available on all platforms
Lots of seldom used
code/features
Monolithic implementation
Unintuitive behaviors woven throughout code base
Not optimized for density/devices
High memory footprintTight coupling to relational conceptsSlide20
What we are doing
Lightweight, extensible
version of EF
Just the commonly used features (and many new features)
Built using modern design patterns
DbContext
and Code First only
Not a
micro-O/RM
Still supports
LINQ, change tracking, unit of work, etc.Support relational & non-relational stores
Not a high level abstraction over all data storesProvide high level services that are useful on all/most storesNon-common concerns handled by provider extensionsSlide21
Design principles
Keep
EF6
patterns
Only break from existing patterns where there is good
reason
Pay per play
Simpler apps will require fewer resources
Low
memory
footprintExtensibleSimple high level API over building blocksEasy to replace/extend individual
building blocks as neededSensible defaults, less magicOnly support magic where it supports long term successSlide22
What about EF6 apps?
You don’t have to upgrade
EF6 is still supported
Updates to EF6 will continue (we’ve done EF6.1 and EF6.1.1 in parallel with EF7)
Not all EF6 features will be in 7.0.0
We don’t expect everyone to be able to upgrade immediately
Upgrade is a key scenario
Same concepts, same patterns
Some code changes will be neededSlide23
Get involved in EF7
Open source
See
http
://
bit.ly/EFTechEd2014 for links
Nightly builds now available
See
http
://bit.ly/EFTechEd2014 for
linksSlide24
Demos | EF7 sneak peekSlide25
Demo
New data storesSlide26
Demo
New platformsSlide27
DEV-B356 Industrial-Strength Entity Framework
Related content
Find Me Later At Developer Tools Booth Slide28
Visit the Developer Platform & Tools Booth
Having a
friend
buy
your coffee?
Yea, it’s kind of like that.
MSDN Subscribers get up to $150/
mo
in Azure credits.
Stop by the Developer Platform and Tools
booth and
visit the MSDN Subscriptions station to activate your benefits and receive a gift!
http://aka.ms/msdn_teched
3 Steps to New Gear! With Application Insights
Create a Visual Studio Online account http://visualstudio.com
Install Application Insights Tools for Visual Studio Online http://aka.ms/aivsix Come to our booth for a t-shirt and a chance to win!
VSIP QR Tag ContestsVisit our booth to join the hunt for cool prizes!
Alex ParkSlide29
Resources
Microsoft Engineering Stories
How
Microsoft Builds Software
http://
aka.ms/EngineeringStories
Visual Studio
Industry
Partner
Program
Meet Our New Visual Studio Online Partners
or
Join Now.
http://vsipprogram.com
Visual Studio | Integrate
Create Your Own Dev Environment
http://integrate.visualstudio.com
Development tools & services
for
teams
of all sizes
http
://www.visualstudio.com Slide30
Complete an evaluation
and
enter to win!Slide31
Evaluate this session
Scan this
QR
code
to evaluate
this
session.Slide32
©
2014
Microsoft Corporation. All rights reserved. Microsoft, Windows,
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.