SlideShare una empresa de Scribd logo
1 de 30
Template designed by
Introduction to EF 6.x
Paolo Pialorsi
paolo@pialorsi.com
http://www.pialorsi.com/blog.aspx
brought to you by
Consulente, project manager e trainer dal 1996
Oltre 40 certificazioni Microsoft conseguite
Microsoft Certified Solutions Master – SharePoint
Focalizzato su .NET e SharePoint dal 2002
Autore di 10 libri su XML, SOAP, .NET,
LINQ e SharePoint
• Microsoft SharePoint 2013 Developer Reference, Microsoft Press
• Build Windows 8 Apps with Microsoft Visual C# and
Visual Basic Step by Step, Microsoft Press
• Microsoft SharePoint 2010 Developer Reference, Microsoft Press
Speaker alle principali conferenze IT
Chi sono
Entity Framework 6
Let’s start
Official Object Relational Mapper (O/RM) from Microsoft
Included in .NET Framework
Available via NuGet, as well
Available for free on CodePlex
Source code available, ‘cause it is Open Source since EF6!
Great option for business-level data access solutions
But it is an O/RM … don’t expect great performances …
What’s Entity Framework
Developer workflows
New
Database
Existing
Database
Designer Centric Code Centric
Database First
Reverse engineer model in EF Designer
Classes auto-generated from model
Model First
Create model in EF Designer
Generate database from model
Classes auto-generated from model
Code First
Define classes and mapping in code
EF Power Tools provide reverse engineer
Code First
Define classes and mapping in code
Database created from code
Migrations apply model changes to database
Code First & EF Designer
Asynchronous query and save
Connection resiliency
Code-based configuration
Database command interception/logging
Performance improvements
Code First Only
Custom conventions
Insert, update, & delete stored procedures
What’s new in EF6 (1/4)
Open Source!
http://entityframework.codeplex.com/
• Source code
• Nightly builds
• Issue tracking
• Feature specs
• Design meeting notes
Only EF team has commit rights
Same license
Same support
Same quality
What’s new in EF6 (2/4)
From the EF team
Nested entity types
Improved transaction Support
Multiple contexts per database
DbModelBuilder.HasDefaultSchema
Configurable migrations history table
Creating context with an open connection
Enums, spatial and better performance on .NET 4.0
Default transaction isolation level changed to READ_COMMITTED_SNAPSHOT
What’s new in EF6 (3/4)
From external contributors
Custom migrations operations
Improved warm up time for large models
Pluggable pluralization & singularization service
DbModelBuilder.Configurations.AddFromAssembly
DbSet.AddRange/RemoveRange
What’s new in EF6 (4/4)
Usage scenarios
Let’s play with Entity
Framework 6
You can create database from code
You can define custom conventions to “understand” your code-
based model
Main Goals
Override default conventions
Centralized code/data conventions
Avoid error prone configurations and repetitive tasks
Define company-level patterns
Code first with custom conventions
When you start from the code …
… code changes (often?!)
You can make EF keep track of changes
Defining migration paths from one version to another
Code Migrations will generate migration code for you
Code First Migrations
Code First Migrations
Explicit configuration
Data annotations
Custom conventions
Default conventions
Order of Precedence
In case you want to be independent from the database schema
You can use stored procedures to manage data
Or you can even have already existing databases with stored
procedures
For custom business logic during save actions
If you have to support linked servers
You can now use Code First to map stored procedures to actions
You can leverage custom conventions, as well
Code First Stored Procedures
Code First
Stored Procedures
One of the smartest news of EF6!
To improve performances and scalability
To free-up UI threads
Not to parallelize tasks
Only one async query for each DbContext
Async queries
Async Queries
You can reuse already opened DbConnection instances
Finally! 
Exception “Entity Connection can only be constructed with a closed DbConnection”
passed away …
Connection Resiliency
Automatic retry … very useful with Azure SQL Database
Managing Connections
You have always been able to use TransactionScope instances
around EF
Now you can also share DbTransaction
Not really useful if you have a “clean” architecture
But very useful in any other scenario …
Managed Transactions
Connections
and Transactions
Easy way to see what’s happening in SQL
To see how LINQ is converted to T-SQL
No need of SQL Server Profiler
Useful for debugging
Database Command Logging
Instead of <entityFramework>
Inherit a type from DbConfiguration
Automatic discovery of such a type
Automatic dependency injeciton
Then configure EF by code
For instance configure IDbCommandInterceptor
Code Based Configuration
Code Based
Configuration
Entity Framework Power Tools (Beta 4)
Allow to design a code first model
Allow to reverse engineer an existing DB
Procuding the “Code First” code … “after” 
Reverse Engineering Existing DB
Final Thoughts
Shall I use EF in real
business solutions?
You should consider it …
And make a decision based on
• Performances
• Scalability
• Time to market
• Shared knowledge
• Total cost of management
Shall I use EF in real business solutions?
Don’t expect the very best performances you can ever achieve in your life
You have to pay the price for the infrastructure
But you have services back from the infrastructure
If you need super-fast solutions
Use custom ADO.NET code
And pay for it
• Implementation, maintenance, tooling, etc.
If you need “classic” performances
Give EF6 a chance …
Decouple code layer and be ready for any changes in the future
Moreover
Grazie a tutti per la partecipazione
Riceverete il link per il download a slide e demo via email nei
prossimi giorni
Per contattarmi
paolo@devleap.com
Grazie

Más contenido relacionado

La actualidad más candente

Visual Studio 2012 - Tipps & Tricks
Visual Studio 2012 - Tipps & TricksVisual Studio 2012 - Tipps & Tricks
Visual Studio 2012 - Tipps & Tricks
Patric Boscolo
 
Entity framework code first
Entity framework code firstEntity framework code first
Entity framework code first
Confiz
 

La actualidad más candente (20)

Advanced application architecture
Advanced application architectureAdvanced application architecture
Advanced application architecture
 
Spring integration with the Java DSL
Spring integration with the Java DSLSpring integration with the Java DSL
Spring integration with the Java DSL
 
Asp.net c# mvc Training-Day-5 of Day-9
Asp.net c# mvc Training-Day-5 of Day-9Asp.net c# mvc Training-Day-5 of Day-9
Asp.net c# mvc Training-Day-5 of Day-9
 
Getting Started with Flex and PHP
Getting Started with Flex and PHPGetting Started with Flex and PHP
Getting Started with Flex and PHP
 
Entity Framework and Domain Driven Design
Entity Framework and Domain Driven DesignEntity Framework and Domain Driven Design
Entity Framework and Domain Driven Design
 
Lerman Vvs14 Ef Tips And Tricks
Lerman Vvs14  Ef Tips And TricksLerman Vvs14  Ef Tips And Tricks
Lerman Vvs14 Ef Tips And Tricks
 
Visual Studio 2012 - Tipps & Tricks
Visual Studio 2012 - Tipps & TricksVisual Studio 2012 - Tipps & Tricks
Visual Studio 2012 - Tipps & Tricks
 
Spring Integration: from XML to Java DSL
Spring Integration: from XML to Java DSLSpring Integration: from XML to Java DSL
Spring Integration: from XML to Java DSL
 
Hexagonal architecture - message-oriented software design (PHP Barcelona 2015)
Hexagonal architecture - message-oriented software design (PHP Barcelona 2015)Hexagonal architecture - message-oriented software design (PHP Barcelona 2015)
Hexagonal architecture - message-oriented software design (PHP Barcelona 2015)
 
why c++11?
why c++11?why c++11?
why c++11?
 
Implementing DDD with C#
Implementing DDD with C#Implementing DDD with C#
Implementing DDD with C#
 
What's New in ReSharper 9?
What's New in ReSharper 9?What's New in ReSharper 9?
What's New in ReSharper 9?
 
Onion Architecture and the Blog
Onion Architecture and the BlogOnion Architecture and the Blog
Onion Architecture and the Blog
 
Dependency injection presentation
Dependency injection presentationDependency injection presentation
Dependency injection presentation
 
Aspect Oriented Programming
Aspect Oriented ProgrammingAspect Oriented Programming
Aspect Oriented Programming
 
Adapter Design Pattern
Adapter Design PatternAdapter Design Pattern
Adapter Design Pattern
 
Api chaining(tm)
Api chaining(tm)Api chaining(tm)
Api chaining(tm)
 
Zend Framework
Zend FrameworkZend Framework
Zend Framework
 
Entity framework code first
Entity framework code firstEntity framework code first
Entity framework code first
 
Using ADO.NET Entity Framework in Domain Driven Design: A Pattern Approach
Using ADO.NET Entity Framework in Domain Driven Design: A Pattern ApproachUsing ADO.NET Entity Framework in Domain Driven Design: A Pattern Approach
Using ADO.NET Entity Framework in Domain Driven Design: A Pattern Approach
 

Destacado

Ag04 gestire gruppi di lavoro, team multipli e progetti con visual studio alm
Ag04   gestire gruppi di lavoro, team multipli e progetti con visual studio almAg04   gestire gruppi di lavoro, team multipli e progetti con visual studio alm
Ag04 gestire gruppi di lavoro, team multipli e progetti con visual studio alm
DotNetCampus
 
Gam04 introduzione a-netduino_final
Gam04   introduzione a-netduino_finalGam04   introduzione a-netduino_final
Gam04 introduzione a-netduino_final
DotNetCampus
 
Signal r to the-max
Signal r to the-maxSignal r to the-max
Signal r to the-max
DotNetCampus
 
AZURE WEBSITE DEEPDIVE
AZURE WEBSITE DEEPDIVEAZURE WEBSITE DEEPDIVE
AZURE WEBSITE DEEPDIVE
DotNetCampus
 
Ds03 data analysis
Ds03   data analysisDs03   data analysis
Ds03 data analysis
DotNetCampus
 
Win03 design windows store apps
Win03   design windows store appsWin03   design windows store apps
Win03 design windows store apps
DotNetCampus
 
Be05 introduction to sql azure
Be05   introduction to sql azureBe05   introduction to sql azure
Be05 introduction to sql azure
DotNetCampus
 
Javascript task automation
Javascript task automationJavascript task automation
Javascript task automation
DotNetCampus
 
Windows iot barone
Windows iot baroneWindows iot barone
Windows iot barone
DotNetCampus
 
Dnc2015 azure-microservizi-vforusso
Dnc2015 azure-microservizi-vforussoDnc2015 azure-microservizi-vforusso
Dnc2015 azure-microservizi-vforusso
DotNetCampus
 

Destacado (18)

DSTORIE DALLA TRINCEA: TEAM FOUNDATION SERVER IN CASI LIMITE E NON SOLO...
DSTORIE DALLA TRINCEA: TEAM FOUNDATION SERVER IN CASI LIMITE E NON SOLO...DSTORIE DALLA TRINCEA: TEAM FOUNDATION SERVER IN CASI LIMITE E NON SOLO...
DSTORIE DALLA TRINCEA: TEAM FOUNDATION SERVER IN CASI LIMITE E NON SOLO...
 
Formulacion inorganica
Formulacion inorganicaFormulacion inorganica
Formulacion inorganica
 
Ag04 gestire gruppi di lavoro, team multipli e progetti con visual studio alm
Ag04   gestire gruppi di lavoro, team multipli e progetti con visual studio almAg04   gestire gruppi di lavoro, team multipli e progetti con visual studio alm
Ag04 gestire gruppi di lavoro, team multipli e progetti con visual studio alm
 
Gam04 introduzione a-netduino_final
Gam04   introduzione a-netduino_finalGam04   introduzione a-netduino_final
Gam04 introduzione a-netduino_final
 
Signal r to the-max
Signal r to the-maxSignal r to the-max
Signal r to the-max
 
Ds01 data science
Ds01   data scienceDs01   data science
Ds01 data science
 
AZURE WEBSITE DEEPDIVE
AZURE WEBSITE DEEPDIVEAZURE WEBSITE DEEPDIVE
AZURE WEBSITE DEEPDIVE
 
Ds03 data analysis
Ds03   data analysisDs03   data analysis
Ds03 data analysis
 
Newsletter
NewsletterNewsletter
Newsletter
 
CONTINUOUS INTEGRATION CON SQL SERVER
CONTINUOUS INTEGRATION CON SQL SERVERCONTINUOUS INTEGRATION CON SQL SERVER
CONTINUOUS INTEGRATION CON SQL SERVER
 
Win03 design windows store apps
Win03   design windows store appsWin03   design windows store apps
Win03 design windows store apps
 
Be05 introduction to sql azure
Be05   introduction to sql azureBe05   introduction to sql azure
Be05 introduction to sql azure
 
Javascript task automation
Javascript task automationJavascript task automation
Javascript task automation
 
Pigmento pb y cd
Pigmento pb y cdPigmento pb y cd
Pigmento pb y cd
 
Windows iot barone
Windows iot baroneWindows iot barone
Windows iot barone
 
70-483: PROGRAMMING IN C#
70-483: PROGRAMMING IN C#70-483: PROGRAMMING IN C#
70-483: PROGRAMMING IN C#
 
Dnc2015 azure-microservizi-vforusso
Dnc2015 azure-microservizi-vforussoDnc2015 azure-microservizi-vforusso
Dnc2015 azure-microservizi-vforusso
 
70-534: ARCHITECTING MICROSOFT AZURE SOLUTIONS
70-534: ARCHITECTING MICROSOFT AZURE SOLUTIONS70-534: ARCHITECTING MICROSOFT AZURE SOLUTIONS
70-534: ARCHITECTING MICROSOFT AZURE SOLUTIONS
 

Similar a Be04 introduction to ef 6.0

Similar a Be04 introduction to ef 6.0 (20)

Elements of DDD with ASP.NET MVC & Entity Framework Code First
Elements of DDD with ASP.NET MVC & Entity Framework Code FirstElements of DDD with ASP.NET MVC & Entity Framework Code First
Elements of DDD with ASP.NET MVC & Entity Framework Code First
 
Entity framework
Entity frameworkEntity framework
Entity framework
 
Entity Core with Core Microservices.pptx
Entity Core with Core Microservices.pptxEntity Core with Core Microservices.pptx
Entity Core with Core Microservices.pptx
 
VSTO + LOB Apps
VSTO + LOB AppsVSTO + LOB Apps
VSTO + LOB Apps
 
Taking SharePoint 2010 Offline - European Best Practices Conference
Taking SharePoint 2010 Offline - European Best Practices ConferenceTaking SharePoint 2010 Offline - European Best Practices Conference
Taking SharePoint 2010 Offline - European Best Practices Conference
 
Building nTier Applications with Entity Framework Services (Part 1)
Building nTier Applications with Entity Framework Services (Part 1)Building nTier Applications with Entity Framework Services (Part 1)
Building nTier Applications with Entity Framework Services (Part 1)
 
Overview of VS2010 and .NET 4.0
Overview of VS2010 and .NET 4.0Overview of VS2010 and .NET 4.0
Overview of VS2010 and .NET 4.0
 
Entity Framework Core 1.0
Entity Framework Core 1.0Entity Framework Core 1.0
Entity Framework Core 1.0
 
Building nTier Applications with Entity Framework Services (Part 1)
Building nTier Applications with Entity Framework Services (Part 1)Building nTier Applications with Entity Framework Services (Part 1)
Building nTier Applications with Entity Framework Services (Part 1)
 
05 entity framework
05 entity framework05 entity framework
05 entity framework
 
The ultimate cheat sheet on .net core, .net framework, and .net standard
The ultimate cheat sheet on .net core, .net framework, and .net standardThe ultimate cheat sheet on .net core, .net framework, and .net standard
The ultimate cheat sheet on .net core, .net framework, and .net standard
 
VSTO + LOB Apps Information Matters
VSTO + LOB Apps Information MattersVSTO + LOB Apps Information Matters
VSTO + LOB Apps Information Matters
 
Domain Modeling & Full-Stack Web Development F#
Domain Modeling & Full-Stack Web Development F#Domain Modeling & Full-Stack Web Development F#
Domain Modeling & Full-Stack Web Development F#
 
13 - Panorama Necto 14 building models - visualization & data discovery solu...
13  - Panorama Necto 14 building models - visualization & data discovery solu...13  - Panorama Necto 14 building models - visualization & data discovery solu...
13 - Panorama Necto 14 building models - visualization & data discovery solu...
 
Php Frameworks
Php FrameworksPhp Frameworks
Php Frameworks
 
Bp205
Bp205Bp205
Bp205
 
JMP201 Introduction to IBM Lotus Notes and IBM Lotus Domino Integration with ...
JMP201 Introduction to IBM Lotus Notes and IBM Lotus Domino Integration with ...JMP201 Introduction to IBM Lotus Notes and IBM Lotus Domino Integration with ...
JMP201 Introduction to IBM Lotus Notes and IBM Lotus Domino Integration with ...
 
Flexible delivery options
Flexible delivery options Flexible delivery options
Flexible delivery options
 
Ef code first
Ef code firstEf code first
Ef code first
 
ILUG 2007 - Notes and Office Integration
ILUG 2007 - Notes and Office IntegrationILUG 2007 - Notes and Office Integration
ILUG 2007 - Notes and Office Integration
 

Más de DotNetCampus

Más de DotNetCampus (20)

ARCHITETTURA DI UN'APPLICAZIONE SCALABILE
ARCHITETTURA DI UN'APPLICAZIONE SCALABILEARCHITETTURA DI UN'APPLICAZIONE SCALABILE
ARCHITETTURA DI UN'APPLICAZIONE SCALABILE
 
MICROSOFT E IL MONDO IOT
MICROSOFT E IL MONDO IOTMICROSOFT E IL MONDO IOT
MICROSOFT E IL MONDO IOT
 
70-485: ADVANCED OF DEVELOPING WINDOWS STORE APPS USING C#
70-485: ADVANCED OF DEVELOPING WINDOWS STORE APPS USING C#70-485: ADVANCED OF DEVELOPING WINDOWS STORE APPS USING C#
70-485: ADVANCED OF DEVELOPING WINDOWS STORE APPS USING C#
 
TUTTO SU VISUAL STUDIO ALM 2015
TUTTO SU VISUAL STUDIO ALM 2015TUTTO SU VISUAL STUDIO ALM 2015
TUTTO SU VISUAL STUDIO ALM 2015
 
PREDICT THE FUTURE , MACHINE LEARNING & BIG DATA
PREDICT THE FUTURE , MACHINE LEARNING & BIG DATAPREDICT THE FUTURE , MACHINE LEARNING & BIG DATA
PREDICT THE FUTURE , MACHINE LEARNING & BIG DATA
 
DESKTOP AND CLIENT VIRTUALIZATION: NEW WORKSTYLES WITH MICROSOFT VDI
DESKTOP AND CLIENT VIRTUALIZATION: NEW WORKSTYLES WITH MICROSOFT VDIDESKTOP AND CLIENT VIRTUALIZATION: NEW WORKSTYLES WITH MICROSOFT VDI
DESKTOP AND CLIENT VIRTUALIZATION: NEW WORKSTYLES WITH MICROSOFT VDI
 
FROM ON-PREMISE TO THE HYBRID CLOUD WITH MICROSOFT AZURE
FROM ON-PREMISE TO THE HYBRID CLOUD WITH MICROSOFT AZUREFROM ON-PREMISE TO THE HYBRID CLOUD WITH MICROSOFT AZURE
FROM ON-PREMISE TO THE HYBRID CLOUD WITH MICROSOFT AZURE
 
SHAREPOINT 2016 - WHAT'S NEW
SHAREPOINT 2016 - WHAT'S NEWSHAREPOINT 2016 - WHAT'S NEW
SHAREPOINT 2016 - WHAT'S NEW
 
COSTRUISCI IL TUO DEVICE
COSTRUISCI IL TUO DEVICECOSTRUISCI IL TUO DEVICE
COSTRUISCI IL TUO DEVICE
 
SVILUPPARE PER MICROSOFT BAND
SVILUPPARE PER MICROSOFT BANDSVILUPPARE PER MICROSOFT BAND
SVILUPPARE PER MICROSOFT BAND
 
INTERFACCE GRAFICHE CON UNITY3D 4.6: IL GIOCO NON BASTA!
INTERFACCE GRAFICHE CON UNITY3D 4.6: IL GIOCO NON BASTA!INTERFACCE GRAFICHE CON UNITY3D 4.6: IL GIOCO NON BASTA!
INTERFACCE GRAFICHE CON UNITY3D 4.6: IL GIOCO NON BASTA!
 
WINDOWS PHONE APPS IN C++
WINDOWS PHONE APPS IN C++WINDOWS PHONE APPS IN C++
WINDOWS PHONE APPS IN C++
 
AZURE NOTIFICATION HUB
AZURE NOTIFICATION HUBAZURE NOTIFICATION HUB
AZURE NOTIFICATION HUB
 
SFRUTTARE I MICROSOFT AZURE MOBILE SERVICES CON XAMARIN.FORMS
SFRUTTARE I MICROSOFT AZURE MOBILE SERVICES CON XAMARIN.FORMSSFRUTTARE I MICROSOFT AZURE MOBILE SERVICES CON XAMARIN.FORMS
SFRUTTARE I MICROSOFT AZURE MOBILE SERVICES CON XAMARIN.FORMS
 
INTRO TO XAMARIN
INTRO TO XAMARININTRO TO XAMARIN
INTRO TO XAMARIN
 
UNIVERSAL APP IN TUTTE LE SALSE: PHONE, TABLET, PC, XBOX E IOT
UNIVERSAL APP IN TUTTE LE SALSE: PHONE, TABLET, PC, XBOX E IOTUNIVERSAL APP IN TUTTE LE SALSE: PHONE, TABLET, PC, XBOX E IOT
UNIVERSAL APP IN TUTTE LE SALSE: PHONE, TABLET, PC, XBOX E IOT
 
SFRUTTARE CORTANA E LE SPEECH API NELLE NOSTRE APP
SFRUTTARE CORTANA E LE SPEECH API NELLE NOSTRE APPSFRUTTARE CORTANA E LE SPEECH API NELLE NOSTRE APP
SFRUTTARE CORTANA E LE SPEECH API NELLE NOSTRE APP
 
APPSTUDIO: DA ZERO ALLO STORE IN 50 MINUTI!
APPSTUDIO: DA ZERO ALLO STORE IN 50 MINUTI!APPSTUDIO: DA ZERO ALLO STORE IN 50 MINUTI!
APPSTUDIO: DA ZERO ALLO STORE IN 50 MINUTI!
 
SIGNALR TO-THE-MAX: VERSO IL WEB ED OLTRE!
SIGNALR TO-THE-MAX: VERSO IL WEB ED OLTRE!SIGNALR TO-THE-MAX: VERSO IL WEB ED OLTRE!
SIGNALR TO-THE-MAX: VERSO IL WEB ED OLTRE!
 
SVILUPPARE E GESTIRE ARCHITETTURE A MICROSERVIZI SU AZURE
SVILUPPARE E GESTIRE ARCHITETTURE A MICROSERVIZI SU AZURESVILUPPARE E GESTIRE ARCHITETTURE A MICROSERVIZI SU AZURE
SVILUPPARE E GESTIRE ARCHITETTURE A MICROSERVIZI SU AZURE
 

Último

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 

Último (20)

Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 

Be04 introduction to ef 6.0

  • 1. Template designed by Introduction to EF 6.x Paolo Pialorsi paolo@pialorsi.com http://www.pialorsi.com/blog.aspx
  • 3. Consulente, project manager e trainer dal 1996 Oltre 40 certificazioni Microsoft conseguite Microsoft Certified Solutions Master – SharePoint Focalizzato su .NET e SharePoint dal 2002 Autore di 10 libri su XML, SOAP, .NET, LINQ e SharePoint • Microsoft SharePoint 2013 Developer Reference, Microsoft Press • Build Windows 8 Apps with Microsoft Visual C# and Visual Basic Step by Step, Microsoft Press • Microsoft SharePoint 2010 Developer Reference, Microsoft Press Speaker alle principali conferenze IT Chi sono
  • 5. Official Object Relational Mapper (O/RM) from Microsoft Included in .NET Framework Available via NuGet, as well Available for free on CodePlex Source code available, ‘cause it is Open Source since EF6! Great option for business-level data access solutions But it is an O/RM … don’t expect great performances … What’s Entity Framework
  • 6. Developer workflows New Database Existing Database Designer Centric Code Centric Database First Reverse engineer model in EF Designer Classes auto-generated from model Model First Create model in EF Designer Generate database from model Classes auto-generated from model Code First Define classes and mapping in code EF Power Tools provide reverse engineer Code First Define classes and mapping in code Database created from code Migrations apply model changes to database
  • 7. Code First & EF Designer Asynchronous query and save Connection resiliency Code-based configuration Database command interception/logging Performance improvements Code First Only Custom conventions Insert, update, & delete stored procedures What’s new in EF6 (1/4)
  • 8. Open Source! http://entityframework.codeplex.com/ • Source code • Nightly builds • Issue tracking • Feature specs • Design meeting notes Only EF team has commit rights Same license Same support Same quality What’s new in EF6 (2/4)
  • 9. From the EF team Nested entity types Improved transaction Support Multiple contexts per database DbModelBuilder.HasDefaultSchema Configurable migrations history table Creating context with an open connection Enums, spatial and better performance on .NET 4.0 Default transaction isolation level changed to READ_COMMITTED_SNAPSHOT What’s new in EF6 (3/4)
  • 10. From external contributors Custom migrations operations Improved warm up time for large models Pluggable pluralization & singularization service DbModelBuilder.Configurations.AddFromAssembly DbSet.AddRange/RemoveRange What’s new in EF6 (4/4)
  • 11. Usage scenarios Let’s play with Entity Framework 6
  • 12. You can create database from code You can define custom conventions to “understand” your code- based model Main Goals Override default conventions Centralized code/data conventions Avoid error prone configurations and repetitive tasks Define company-level patterns Code first with custom conventions
  • 13. When you start from the code … … code changes (often?!) You can make EF keep track of changes Defining migration paths from one version to another Code Migrations will generate migration code for you Code First Migrations
  • 15. Explicit configuration Data annotations Custom conventions Default conventions Order of Precedence
  • 16. In case you want to be independent from the database schema You can use stored procedures to manage data Or you can even have already existing databases with stored procedures For custom business logic during save actions If you have to support linked servers You can now use Code First to map stored procedures to actions You can leverage custom conventions, as well Code First Stored Procedures
  • 18. One of the smartest news of EF6! To improve performances and scalability To free-up UI threads Not to parallelize tasks Only one async query for each DbContext Async queries
  • 20. You can reuse already opened DbConnection instances Finally!  Exception “Entity Connection can only be constructed with a closed DbConnection” passed away … Connection Resiliency Automatic retry … very useful with Azure SQL Database Managing Connections
  • 21. You have always been able to use TransactionScope instances around EF Now you can also share DbTransaction Not really useful if you have a “clean” architecture But very useful in any other scenario … Managed Transactions
  • 23. Easy way to see what’s happening in SQL To see how LINQ is converted to T-SQL No need of SQL Server Profiler Useful for debugging Database Command Logging
  • 24. Instead of <entityFramework> Inherit a type from DbConfiguration Automatic discovery of such a type Automatic dependency injeciton Then configure EF by code For instance configure IDbCommandInterceptor Code Based Configuration
  • 26. Entity Framework Power Tools (Beta 4) Allow to design a code first model Allow to reverse engineer an existing DB Procuding the “Code First” code … “after”  Reverse Engineering Existing DB
  • 27. Final Thoughts Shall I use EF in real business solutions?
  • 28. You should consider it … And make a decision based on • Performances • Scalability • Time to market • Shared knowledge • Total cost of management Shall I use EF in real business solutions?
  • 29. Don’t expect the very best performances you can ever achieve in your life You have to pay the price for the infrastructure But you have services back from the infrastructure If you need super-fast solutions Use custom ADO.NET code And pay for it • Implementation, maintenance, tooling, etc. If you need “classic” performances Give EF6 a chance … Decouple code layer and be ready for any changes in the future Moreover
  • 30. Grazie a tutti per la partecipazione Riceverete il link per il download a slide e demo via email nei prossimi giorni Per contattarmi paolo@devleap.com Grazie