eestec summer school 2012 - entity framework - erni durdevic
DESCRIPTION
EESTEC Summer School 2012 - Web Development class Entity Framework by Erni DurdevicTRANSCRIPT
Sql data access (Classic style)
SQL String: «SELECT x, y FROM TblPoints»
Entity Framework
Entity
Framework
«SQL»LINQ
Entity Framework
takes care of the
DB interactions
and makes it
easy to access
relational data.
Sql data access with EF
Farm
Pig
s
Ducks
Rabbits
Farm Model
What is the Model?
Farm
Pig
s
Duck
s
Rabb
its
Farm DB
Database
Farm
Pig
s
Duck
s
Rabb
its
Farm DBFarm Model
Our software
Entity Framework model
Farm DBFarm Model
Farm DB Farm Model
EF Model
Database-First
Code-first
EF –DB first
DB First
When you have a ready DB
and you want to access the
existing data
If you better prefer to build
the database first, and
automatically create the
model
EF –DB first Demo:
› Create a DB
› Import it in into Visual Studio
› See what has been generated
EDMX
Mappings
C#
Class diagram
EF –Model first
Model First
› When you are building a new
solution from scratch
(New approach)
EF –Model first
Demo...
› Create the model
› Create an empty DB
› Generate the DB schema
Demo
› Reference the Entity solution in a
separate project
Add reference
Copy the connection string
Reference System.Data.Entity
› Query data with LINQ
Select
Update
Insert
Delete
EF –Model first