Enviar pesquisa
Carregar
Entity Framework - Entity Data Model (edm)
•
11 gostaram
•
4,139 visualizações
Eyal Vardi
Seguir
Entity Framework - Entity Data Model (edm)
Leia menos
Leia mais
Tecnologia
Denunciar
Compartilhar
Denunciar
Compartilhar
1 de 43
Recomendados
Entity Framework Overview
Entity Framework Overview
Eyal Vardi
Entity Framework - Queries
Entity Framework - Queries
Eyal Vardi
Entity Framework - Object Services
Entity Framework - Object Services
Eyal Vardi
Ef code first
Ef code first
ZealousysDev
Learn Entity Framework in a day with Code First, Model First and Database First
Learn Entity Framework in a day with Code First, Model First and Database First
Jibran Rasheed Khan
Introducing Entity Framework 4.0
Introducing Entity Framework 4.0
Bishoy Demian
Entity framework code first
Entity framework code first
Confiz
Getting started with entity framework
Getting started with entity framework
Lushanthan Sivaneasharajah
Recomendados
Entity Framework Overview
Entity Framework Overview
Eyal Vardi
Entity Framework - Queries
Entity Framework - Queries
Eyal Vardi
Entity Framework - Object Services
Entity Framework - Object Services
Eyal Vardi
Ef code first
Ef code first
ZealousysDev
Learn Entity Framework in a day with Code First, Model First and Database First
Learn Entity Framework in a day with Code First, Model First and Database First
Jibran Rasheed Khan
Introducing Entity Framework 4.0
Introducing Entity Framework 4.0
Bishoy Demian
Entity framework code first
Entity framework code first
Confiz
Getting started with entity framework
Getting started with entity framework
Lushanthan Sivaneasharajah
ADO.NET Entity Framework
ADO.NET Entity Framework
Doncho Minkov
Introducing the Entity Framework
Introducing the Entity Framework
LearnNowOnline
Entity Framework Database and Code First
Entity Framework Database and Code First
James Johnson
Entity framework 4.0
Entity framework 4.0
Abhishek Sur
ADO.NET Entity Framework
ADO.NET Entity Framework
ukdpe
Entity Framework v2 Best Practices
Entity Framework v2 Best Practices
Andri Yadi
Entity Framework 4
Entity Framework 4
Stefano Paluello
Microsoft Entity Framework
Microsoft Entity Framework
Mahmoud Tolba
Free Hibernate Tutorial | VirtualNuggets
Free Hibernate Tutorial | VirtualNuggets
Virtual Nuggets
LINQ to Relational in Visual Studio 2008 SP1
LINQ to Relational in Visual Studio 2008 SP1
ukdpe
Hibernate
Hibernate
Murali Pachiyappan
Building nTier Applications with Entity Framework Services (Part 1)
Building nTier Applications with Entity Framework Services (Part 1)
David McCarter
Day5
Day5
madamewoolf
Building nTier Applications with Entity Framework Services (Part 1)
Building nTier Applications with Entity Framework Services (Part 1)
David McCarter
Hibernate
Hibernate
Ajay K
Introduction to Hibernate Framework
Introduction to Hibernate Framework
Raveendra R
Ado .net
Ado .net
Manish Singh
Microsoft Database Options
Microsoft Database Options
David Chou
Ado.net
Ado.net
Sangeetha Rangarajan
Ado.net
Ado.net
dina1985vlr
Model Driven Architecture (MDA): Motivations, Status & Future
Model Driven Architecture (MDA): Motivations, Status & Future
elliando dias
Ado.net entity framework_4.0
Ado.net entity framework_4.0
Rishu Mehra
Mais conteúdo relacionado
Mais procurados
ADO.NET Entity Framework
ADO.NET Entity Framework
Doncho Minkov
Introducing the Entity Framework
Introducing the Entity Framework
LearnNowOnline
Entity Framework Database and Code First
Entity Framework Database and Code First
James Johnson
Entity framework 4.0
Entity framework 4.0
Abhishek Sur
ADO.NET Entity Framework
ADO.NET Entity Framework
ukdpe
Entity Framework v2 Best Practices
Entity Framework v2 Best Practices
Andri Yadi
Entity Framework 4
Entity Framework 4
Stefano Paluello
Microsoft Entity Framework
Microsoft Entity Framework
Mahmoud Tolba
Free Hibernate Tutorial | VirtualNuggets
Free Hibernate Tutorial | VirtualNuggets
Virtual Nuggets
LINQ to Relational in Visual Studio 2008 SP1
LINQ to Relational in Visual Studio 2008 SP1
ukdpe
Hibernate
Hibernate
Murali Pachiyappan
Building nTier Applications with Entity Framework Services (Part 1)
Building nTier Applications with Entity Framework Services (Part 1)
David McCarter
Day5
Day5
madamewoolf
Building nTier Applications with Entity Framework Services (Part 1)
Building nTier Applications with Entity Framework Services (Part 1)
David McCarter
Hibernate
Hibernate
Ajay K
Introduction to Hibernate Framework
Introduction to Hibernate Framework
Raveendra R
Ado .net
Ado .net
Manish Singh
Microsoft Database Options
Microsoft Database Options
David Chou
Ado.net
Ado.net
Sangeetha Rangarajan
Ado.net
Ado.net
dina1985vlr
Mais procurados
(20)
ADO.NET Entity Framework
ADO.NET Entity Framework
Introducing the Entity Framework
Introducing the Entity Framework
Entity Framework Database and Code First
Entity Framework Database and Code First
Entity framework 4.0
Entity framework 4.0
ADO.NET Entity Framework
ADO.NET Entity Framework
Entity Framework v2 Best Practices
Entity Framework v2 Best Practices
Entity Framework 4
Entity Framework 4
Microsoft Entity Framework
Microsoft Entity Framework
Free Hibernate Tutorial | VirtualNuggets
Free Hibernate Tutorial | VirtualNuggets
LINQ to Relational in Visual Studio 2008 SP1
LINQ to Relational in Visual Studio 2008 SP1
Hibernate
Hibernate
Building nTier Applications with Entity Framework Services (Part 1)
Building nTier Applications with Entity Framework Services (Part 1)
Day5
Day5
Building nTier Applications with Entity Framework Services (Part 1)
Building nTier Applications with Entity Framework Services (Part 1)
Hibernate
Hibernate
Introduction to Hibernate Framework
Introduction to Hibernate Framework
Ado .net
Ado .net
Microsoft Database Options
Microsoft Database Options
Ado.net
Ado.net
Ado.net
Ado.net
Semelhante a Entity Framework - Entity Data Model (edm)
Model Driven Architecture (MDA): Motivations, Status & Future
Model Driven Architecture (MDA): Motivations, Status & Future
elliando dias
Ado.net entity framework_4.0
Ado.net entity framework_4.0
Rishu Mehra
Entity Framework v1 and v2
Entity Framework v1 and v2
Eric Nelson
ADO.NET Entity Framework
ADO.NET Entity Framework
Hasnain Iqbal
Building N Tier Applications With Entity Framework Services 2010
Building N Tier Applications With Entity Framework Services 2010
David McCarter
Entity Framework Overview
Entity Framework Overview
Eric Nelson
Entity framework
Entity framework
Tamer Elshahat
Entity Framework V1 and V2
Entity Framework V1 and V2
ukdpe
Oracle ADF Overview
Oracle ADF Overview
Bahaa Farouk
Aras PLM Roadmap
Aras PLM Roadmap
Aras
Modelling and code generation in .NET at Icinetic
Modelling and code generation in .NET at Icinetic
Icinetic
Modelling and code generation in .NET at Icinetic
Modelling and code generation in .NET at Icinetic
Pedro J. Molina
Mahmoud Mustafa Cv
Mahmoud Mustafa Cv
Mahmoud Mustafa
Elements of DDD with ASP.NET MVC & Entity Framework Code First
Elements of DDD with ASP.NET MVC & Entity Framework Code First
Enea Gabriel
Shin J2 Ee Programming Half Day
Shin J2 Ee Programming Half Day
lokendralodha
Implicit Middleware
Implicit Middleware
Till Riedel
.NET Core, ASP.NET Core Course, Session 13
.NET Core, ASP.NET Core Course, Session 13
aminmesbahi
Compositional AI: Fusion of AI/ML Services
Compositional AI: Fusion of AI/ML Services
Debmalya Biswas
RESTful SOA and the Spring Framework (EMCWorld 2011)
RESTful SOA and the Spring Framework (EMCWorld 2011)
EMC
MoDisco Eclipse-OMG Symp 2010
MoDisco Eclipse-OMG Symp 2010
fmadiot
Semelhante a Entity Framework - Entity Data Model (edm)
(20)
Model Driven Architecture (MDA): Motivations, Status & Future
Model Driven Architecture (MDA): Motivations, Status & Future
Ado.net entity framework_4.0
Ado.net entity framework_4.0
Entity Framework v1 and v2
Entity Framework v1 and v2
ADO.NET Entity Framework
ADO.NET Entity Framework
Building N Tier Applications With Entity Framework Services 2010
Building N Tier Applications With Entity Framework Services 2010
Entity Framework Overview
Entity Framework Overview
Entity framework
Entity framework
Entity Framework V1 and V2
Entity Framework V1 and V2
Oracle ADF Overview
Oracle ADF Overview
Aras PLM Roadmap
Aras PLM Roadmap
Modelling and code generation in .NET at Icinetic
Modelling and code generation in .NET at Icinetic
Modelling and code generation in .NET at Icinetic
Modelling and code generation in .NET at Icinetic
Mahmoud Mustafa Cv
Mahmoud Mustafa Cv
Elements of DDD with ASP.NET MVC & Entity Framework Code First
Elements of DDD with ASP.NET MVC & Entity Framework Code First
Shin J2 Ee Programming Half Day
Shin J2 Ee Programming Half Day
Implicit Middleware
Implicit Middleware
.NET Core, ASP.NET Core Course, Session 13
.NET Core, ASP.NET Core Course, Session 13
Compositional AI: Fusion of AI/ML Services
Compositional AI: Fusion of AI/ML Services
RESTful SOA and the Spring Framework (EMCWorld 2011)
RESTful SOA and the Spring Framework (EMCWorld 2011)
MoDisco Eclipse-OMG Symp 2010
MoDisco Eclipse-OMG Symp 2010
Mais de Eyal Vardi
Why magic
Why magic
Eyal Vardi
Smart Contract
Smart Contract
Eyal Vardi
Rachel's grandmother's recipes
Rachel's grandmother's recipes
Eyal Vardi
Performance Optimization In Angular 2
Performance Optimization In Angular 2
Eyal Vardi
Angular 2 Architecture (Bucharest 26/10/2016)
Angular 2 Architecture (Bucharest 26/10/2016)
Eyal Vardi
Angular 2 NgModule
Angular 2 NgModule
Eyal Vardi
Upgrading from Angular 1.x to Angular 2.x
Upgrading from Angular 1.x to Angular 2.x
Eyal Vardi
Angular 2 - Ahead of-time Compilation
Angular 2 - Ahead of-time Compilation
Eyal Vardi
Routing And Navigation
Routing And Navigation
Eyal Vardi
Angular 2 Architecture
Angular 2 Architecture
Eyal Vardi
Angular 1.x vs. Angular 2.x
Angular 1.x vs. Angular 2.x
Eyal Vardi
Angular 2.0 Views
Angular 2.0 Views
Eyal Vardi
Component lifecycle hooks in Angular 2.0
Component lifecycle hooks in Angular 2.0
Eyal Vardi
Template syntax in Angular 2.0
Template syntax in Angular 2.0
Eyal Vardi
Http Communication in Angular 2.0
Http Communication in Angular 2.0
Eyal Vardi
Angular 2.0 Dependency injection
Angular 2.0 Dependency injection
Eyal Vardi
Angular 2.0 Routing and Navigation
Angular 2.0 Routing and Navigation
Eyal Vardi
Async & Parallel in JavaScript
Async & Parallel in JavaScript
Eyal Vardi
Angular 2.0 Pipes
Angular 2.0 Pipes
Eyal Vardi
Angular 2.0 forms
Angular 2.0 forms
Eyal Vardi
Mais de Eyal Vardi
(20)
Why magic
Why magic
Smart Contract
Smart Contract
Rachel's grandmother's recipes
Rachel's grandmother's recipes
Performance Optimization In Angular 2
Performance Optimization In Angular 2
Angular 2 Architecture (Bucharest 26/10/2016)
Angular 2 Architecture (Bucharest 26/10/2016)
Angular 2 NgModule
Angular 2 NgModule
Upgrading from Angular 1.x to Angular 2.x
Upgrading from Angular 1.x to Angular 2.x
Angular 2 - Ahead of-time Compilation
Angular 2 - Ahead of-time Compilation
Routing And Navigation
Routing And Navigation
Angular 2 Architecture
Angular 2 Architecture
Angular 1.x vs. Angular 2.x
Angular 1.x vs. Angular 2.x
Angular 2.0 Views
Angular 2.0 Views
Component lifecycle hooks in Angular 2.0
Component lifecycle hooks in Angular 2.0
Template syntax in Angular 2.0
Template syntax in Angular 2.0
Http Communication in Angular 2.0
Http Communication in Angular 2.0
Angular 2.0 Dependency injection
Angular 2.0 Dependency injection
Angular 2.0 Routing and Navigation
Angular 2.0 Routing and Navigation
Async & Parallel in JavaScript
Async & Parallel in JavaScript
Angular 2.0 Pipes
Angular 2.0 Pipes
Angular 2.0 forms
Angular 2.0 forms
Último
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
NavinnSomaal
How to write a Business Continuity Plan
How to write a Business Continuity Plan
Databarracks
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
Kalema Edgar
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
Alex Barbosa Coqueiro
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
Dilum Bandara
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
LoriGlavin3
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
LoriGlavin3
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
BookNet Canada
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
DianaGray10
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Mark Simos
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
LoriGlavin3
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
BookNet Canada
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
Commit University
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
Florian Wilhelm
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
Dubai Multi Commodity Centre
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
Raghuram Pandurangan
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Precisely
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
LoriGlavin3
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
LoriGlavin3
Último
(20)
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
How to write a Business Continuity Plan
How to write a Business Continuity Plan
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
Entity Framework - Entity Data Model (edm)
1.
Entity Data Model
(EDM) Eyal Vardi CEO E4D Solutions LTD Microsoft MVP Visual C# blog: www.eVardi.com
2.
EF Architecture
LINQ to Entities Entity SQL EDM Conceptual Object Services Model Mapping Entity Client Provider Storage ADO.NET Provider Model SQLServer © 2010 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
3.
Entity Data Model
(EDM) The EDM is the link between the model and the database. The EDM is that it decouples your application from the underlying store. Entity Data Model (EDM) Conceptual Storage Mapping Model Model Storage (MSL) (CSDL) (SSDL) © 2010 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
4.
Agenda
LINQ to Entity EDM Entities SQL Conceptu Object Services al Model Mapping Entity Client Provider Storage Model ADO.NET Provider EF Architecture Development Approaches Entity Data Model (EDM) Object Services Querying & Loading Entities © 2010 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
5.
LINQ to
Entity EDM Entities SQL Conceptu Object Services al Model Mapping Entity Client Provider Storage Model ADO.NET Provider Development Approaches © 2010 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
6.
Database First
If you already have a database, the Entity Framework can automatically generate a data model that consists of classes and properties that correspond to existing database objects such as tables and columns. Generated Database First Data Model DB (.edmx) © 2010 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
7.
Model First
If you don't yet have a database, you can begin by creating a model using the Entity Framework designer in Visual Studio. The designer can generate DDL (data definition language) statements to create the database. Data Model Model First Generated (.edmx) DB © 2010 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
8.
Code First
Whether you have an existing database or not, you can code your own classes and properties that correspond to tables and columns and use them with the Entity Framework without an .edmx file. Data Model Code First Generated (Classes) DB Generated Code First Data Model DB (Classes) © 2010 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
9.
Conventions
The pluralized forms of entity class names are used as table names. Entity property names are used for column names. Entity properties that are named ID or classnameID are recognized as primary key properties. © 2010 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
10.
LINQ to
Entity EDM Entities SQL Conceptu Object Services al Model Mapping Entity Client Provider Storage Model ADO.NET Provider Database Configuration © 2010 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
11.
Database Configuration(Code First)
DB Name Connection Name (no config file ) © 2010 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
12.
Initialization Strategy (Code
First) Initialize the database, the first time a context is used in an AppDomain. The following initializers are supported: CreateDatabaseIfNotExist DropCreateDatabaseAlways DropCreateDatabaseIfModelChanges © 2010 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
13.
Seeding a Database
(Code First) The Seed method takes whatever you put in the context and saves it to the database. you don’t need to call SaveChanges but you DO need to be sure to call the base Seed method at the end. Database.SetInitializer( new DbInit() ); © 2010 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
14.
Database Configuration
Model First is different from Code First in that your Entity Data Model (EDM) already exists. © 2010 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
15.
LINQ to
Entity EDM Entities SQL Conceptu Object Services al Model Mapping Entity Client Provider Storage Model ADO.NET Provider Data Annotations © 2010 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
16.
Data Annotations
Code first gives you two ways to add these configurations to your classes. Data Annotations Fluent API © 2010 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
17.
Data Annotations
Map your code first classes to a pre-existing database. Key DatabaseGenerated NotMapped InverseProperty ComplexType ForeignKey ConcurrencyCheck TimeStamp Table and Column MSDN link © 2010 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
18.
Validation Attribures
Validation your code first classes. Required StringLength MaxLength & MinLength public class ProductMD { [StringLength(50)] [Required] public object Name { get; set; } [Required] public object Weight { get; set; } } © 2010 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
19.
Validations
DbContext automatically validates entities before saving them to the database. Validation is performed based on model facets as well as on data annotations. Entities can also be validated on demand. © 2010 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
20.
Data Annotations © 2010
E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
21.
LINQ to
Entity EDM Entities SQL Conceptu Object Services al Model Mapping Entity Client Provider Storage Model ADO.NET Provider Fluent API © 2010 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
22.
Fluent API
Specify additional mapping configuration that will override the default Code First conventions. Map to an existing database schema or to affect the shape of a generated schema. © 2010 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
23.
Fluent API (DbModelBuilder)
Fluent API Exposed through the DbModelBuilder. Properties with Fluent API Types with Fluent API Relationships with Fluent API © 2010 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
24.
Fluent API (Types)
Specifying Complex Type Not to map a CLR entity type to a table in the database Mapping a CLR entity type to a specific table in the database The table-per-hierarchy (TPH) inheritance The table-per-type (TPT) inheritance The table-per-concrete class (TPC) inheritance CLR properties of an entity type to multiple tables in the database Multiple entity types to one table in the database © 2010 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
25.
Fluent API (Types)
Fluent API Samples (Click) © 2010 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
26.
Fluent API (Relationships)
Configuring: a one-to-zero-or-one relationship a relationship where both ends are required a many-to-many relationship a relationship with one navigation property a composite foreign key a foreign key name that does not follow the Code First convention Enabling cascade delete Renaming a foreign key that is not defined in the model © 2010 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
27.
Relationships (HasXXXWithXXX)
Principal Dependent modelBuilder.Entity<Course>() .HasRequired( t => t.Department) .WithMany( t => t.Courses) .HasForeignKey(d => d.DepartmentID) .WillCascadeOnDelete(false); © 2010 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
28.
Fluent API (Relationships)
Fluent API Samples (Click) © 2010 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
29.
Cascade Delete
You can configure cascade delete on a relationship by using the WillCascadeOnDelete method. You can remove these cascade delete conventions by using: modelBuilder.Conventions.Remove<OneToManyCascadeDeleteConvention>() modelBuilder.Conventions.Remove<ManyToManyCascadeDeleteConvention>() modelBuilder.Entity<Course>() .HasRequired( t => t.Department) .WithMany( t => t.Courses) .HasForeignKey(d => d.DepartmentID) .WillCascadeOnDelete(false); © 2010 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
30.
Fluent API (Properties)
Primary & Foreign key Maximum length Required Mapping a CLR property to a specific column in the database Unicode content Data type of a database column Complex type Optimistic concurrency token © 2010 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
31.
Fluent API
(Properties) Fluent API Samples (Click) © 2010 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
32.
LINQ to
Entity EDM Entities SQL Conceptu Object Services al Model Mapping Entity Client Provider Storage Model ADO.NET Provider Inheritance Mapping © 2010 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
33.
Inheritance Mapping
Inheritance mapping strategies: Table per Hierarchy (TPH) Table per Type (TPT) Table per Concrete Type (TPC) © 2010 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
34.
Table per Hierarchy
(TPH) An entire class hierarchy can be mapped to a single table. This table includes columns for all properties of all classes in the hierarchy. © 2010 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
35.
© 2010 E4D
LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
36.
TPH with Fluent
API The code will change the discriminator column name to "BillingDetailType" and the values to "BA" and "CC" for BankAccount and CreditCard respectively: Click here for more information © 2010 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
37.
Table per Type
(TPT) TPT is about representing inheritance relationships as relational foreign key associations. Every class/subclass that declares persistent properties— including abstract classes—has its own table. © 2010 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
38.
© 2010 E4D
LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
39.
TPT with Fluent
API TPT mapping by using ToTable() method. Click here for more information © 2010 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
40.
Table per Concrete
Type (TPC) In TPC type we use exactly one table for each (nonabstract) class. © 2010 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
41.
© 2010 E4D
LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
42.
Click here for
more information © 2010 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
43.
Fluent API © 2010
E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
Notas do Editor
Create the table in the DBAdd the mapping for Person and subclass Customer. <discriminator>PersonType</> in the Person classdiscriminator-value=“Customer” in the subclassRefactorDataProvider to load, save and delete all kind of types