8/6/2019 DocumentsADO.net Entity Framework DevDays
1/29
8/6/2019 DocumentsADO.net Entity Framework DevDays
2/29
ADO.NET ENTITYFRAMEWORK
Mike Taulty
Developer & Platform Group
Microsoft UK
http://www.miketaulty.com
8/6/2019 DocumentsADO.net Entity Framework DevDays
3/29
Entity Framework Key Facts
Extension to the ADO.NET Provider Model
Pluggable to support any database
Functionality Abstracts a model from your store schema
Offers Object Relational Mapping/LINQ and ADO.NET
APIs
Status
Coming in Visual Studio 2008 Sp1, Summer 2008
Currently in VS 2008 Sp1 Beta 1
3 previous independent betas
8/6/2019 DocumentsADO.net Entity Framework DevDays
4/29
ADO.NET Entity Framework
SQL Provider Oracle Provider ...
Entity Provider
Conceptual Model
Store Model
Map
ADO.NET API ORM API
Connection
Command
DataReader
ObjectContext
ObjectQuery
8/6/2019 DocumentsADO.net Entity Framework DevDays
5/29
ADO.NET Entity Framework
SQL Provider Oracle Provider ...
ADO.NET API
Entity Provider
Conceptual Model
Store Model
Map
ORM API
8/6/2019 DocumentsADO.net Entity Framework DevDays
6/29
8/6/2019 DocumentsADO.net Entity Framework DevDays
7/29
DEMOProgramming Entity Framework with LINQ
8/6/2019 DocumentsADO.net Entity Framework DevDays
8/29
Key Classes
State
Management
Connectionprovider
Metadata
MSL SSDLCSDL
CRUD
8/6/2019 DocumentsADO.net Entity Framework DevDays
9/29
8/6/2019 DocumentsADO.net Entity Framework DevDays
10/29
ADO.NET Entity Framework
SQL Provider Oracle Provider ...
ADO.NET API ORM API
Entity Provider
Conceptual Model
Store Model
Map
8/6/2019 DocumentsADO.net Entity Framework DevDays
11/29
DEMOManipulating our Conceptual Model
8/6/2019 DocumentsADO.net Entity Framework DevDays
12/29
ADO.NET Entity Framework
SQL Provider Oracle Provider ...
ORM API
Entity Provider
Conceptual Model
Store Model
Map
ADO.NET API
8/6/2019 DocumentsADO.net Entity Framework DevDays
13/29
8/6/2019 DocumentsADO.net Entity Framework DevDays
14/29
EF Providers in Progress
Vendor DB Support
Microsoft SQL Server
Core Lab Oracle, MySQL, PostgreSQL,
SQLite
IBM DB2, Informix DynamicServer
MySQL AB MySQL
Npgsql PostgreSQL
OpenLink Many via OpenLink ODBC or
JDBC
Phoenix SQLite
DataDirect Oracle, Sybase, SQL Server,
DB2
Firebird Firebird
8/6/2019 DocumentsADO.net Entity Framework DevDays
15/29
Resources
New Data Developer Site
http://www.datadeveloper.net
ADO.NET Team Blog http://blogs.msdn.com/adonet
My website
http://www.miketaulty.com ( search Entity )
8/6/2019 DocumentsADO.net Entity Framework DevDays
16/29
ADO.NET ENTITYFRAMEWORK
Mike Taulty
Developer & Platform Group
Microsoft UK
http://www.miketaulty.com
8/6/2019 DocumentsADO.net Entity Framework DevDays
17/29
8/6/2019 DocumentsADO.net Entity Framework DevDays
18/29
ADO.NET Today
App CodeApp Code
to r
ADO.NETADO.NET
ProvidersProviders
SQL ServerSQL Server
OracleOracle
......
DataReaderDataReader
to r
OracleOracle
CommandCommand
Exec teExec te
Provider Specific (PL/SQL)Provider Specific (PL/SQL)
SELECT * FROM CUSTOMERSSELECT * FROM CUSTOMERS
to r
8/6/2019 DocumentsADO.net Entity Framework DevDays
19/29
ADO.NET Entity Framework
tomer
Conceptual ModelConceptual Model
UK tomer
UKPremi m tomer
MapMap
8/6/2019 DocumentsADO.net Entity Framework DevDays
20/29
8/6/2019 DocumentsADO.net Entity Framework DevDays
21/29
8/6/2019 DocumentsADO.net Entity Framework DevDays
22/29
Programming with Entity SQL
The EntityClient provides the usual
Connection, Command, DataReader
There is no EntityDataAdapter V1.0 the model is read-only
Entity SQL has some additional constructs to
expose the underlying conceptual model
ANYELEMENT CREATEREF DEREF IS OF KEY MULTISET NAVIGATE OFTYPE
OVERLAPS REF ROW SELECT SET TREAT USING
8/6/2019 DocumentsADO.net Entity Framework DevDays
23/29
DEMOProgramming with Entity SQL
8/6/2019 DocumentsADO.net Entity Framework DevDays
24/29
Mapping Examples ( 1 Splitting )Store
Good Customers
IDFirstName
LastName
Bad Customers
ID
ForeName
Surname
CustomersCustomerId
First
Last
Type
EntitiesMapping
Type=G
Type=B
8/6/2019 DocumentsADO.net Entity Framework DevDays
25/29
Mapping Examples ( 2 TPH )Store
Customer
CustomerId
First
Last
EntitiesMapping
Customers
ID
FirstName
LastName
IsPremium
Overdraft
AccountManager PremiumCustomer
Overdraft
AccountManager
?
* Framework also supports TPT
8/6/2019 DocumentsADO.net Entity Framework DevDays
26/29
Mapping Examples ( 3 View + SPs )Store
UkCustomer
CustomerId
Name
EntitiesMapping
ClientView1
select
c.id, c.name
from
customers c
where
c.country =
UK
p_DeleteUkCustomer
p_UpdateUkCustomer
p_InsertUkCustomer
8/6/2019 DocumentsADO.net Entity Framework DevDays
27/29
DEMOQuerying Different Models with Entity SQL
8/6/2019 DocumentsADO.net Entity Framework DevDays
28/29
Programming withLINQ to Entities
New Data Access ORM API implemented in
assembly
System.Data.Entity.dll
Many Namespaces
System.Data.Entity
System.Data.Objects
...
Object Relational Mapping API can be used withor without LINQ
8/6/2019 DocumentsADO.net Entity Framework DevDays
29/29
DEMOProgramming with LINQ to Entities