SlideShare a Scribd company logo
06 | Integrating extra features and looking
forward
Christopher Harrison | Content Developer, Microsoft
Adam Tuliper | Technical Evangelist, Microsoft
Module Overview
• Stored procedures
• Increasing user experience with concurrency detection
• A few best practices
• Looking forward with Entity Framework 7
Stored procedures
Store procedures
• Why use stored procedures?
– Single point to secure – easier permissions
– Know exactly how DB is being queries
• Limits dynamic sql
– Still possible with sprocs, just more manual effort
• In general performance is _not_ a reason
– Virtually the same as sql query (pendulum swings both ways)
Stored procedures
• Support came in EF 6
– Only Fluent API based
• In the past could use procs manually
– var album = Database.SqlQuery<TriviaOption>("dbo.Proc….");
• Could map in the designer (which is going away)
• Code first will generate procedures for
– Insert, Delete, Update
• Wait – why no Select?
DEMODEMO
Integrating stored procedures
Increasing user experience with
concurrency detection
Concurrency
• As Christopher showed, easy to implement via concurrency token
– [TimeStamp]
– modelBuilder.Entity<YourEntity>()
.Property(e => e.Timestamp)
.IsRowVersion();
• Change detection can be enhanced via MVC Action Filters
• Let’s give the user the choice on how to proceed
DEMODEMO
Concurrency detection and user choice
A few best practices
Helpful hints in a web world
• Since the web layers (controller to view) are disconnected
– Always convert results to IEnumerable via .ToList()
• Ex. context.Albums.Where(o=>o.Title.Contains(search).ToList()
• Disable lazy loading in web environments
– context.Configuration.LazyLoadingEnabled = false;
– Use .Include to load related entities
– context.Albums.Include(o=>o.AlbumDetails)
• DbContext is not thread safe. Do not cache it!
– Always dispose DbContext when done
Context lifetime
• When context is gone, connection is gone
– Can’t (and shouldn’t) use connection from MVC view
– Get data, send to view
• Always execute result set when needed before exiting using()
using (var context = new MusicContext())
{
var albums = context.Albums
.Where(o=>o.Title.Contains(search))
.ToList());
return View(albums);
}
Watch out for…
• For complex joins, keep an eye on queries
– Remember context.Database.Log = s => Debug.WriteLine(s);
• Doing lots of inserts? AutoDetectChangesEnabled = false;
– EF detects changes on add to context and on save
– Can turn off and on again in same context lifetime
{
context.Configuration.AutoDetectChangesEnabled = false;
Do something
context.Configuration.AutoDetectChangesEnabled = true;
}
Async when appropriate
• EF supports async queries
– Async allows current thread to be used elsewhere
• Useful in case of network, db delays (long operations)
– Although not all the time, caution of overloading db
public async Task<ActionResult> Create(…)
{
if (ModelState.IsValid)
{
db.Albums.Add(album);
await db.SaveChangesAsync();
return RedirectToAction("Index");
}
return View(album);
}
Consider Connection resiliency
• This is a connection retry policy
• Works great with async
• Four modes
– DefaultExecutionStrategy
– DefaultSqlExecutionStrategy
– DbExecutionStrategy
– SqlAzureExecutionStrategy
• throws RetryLimitExceededException
DEMODEMO
Connection Resiliency & Async
Looking forward with Entity Framework 7
Notable new features
• Designer has been removed – Code First Only
• Rewritten from ground up with performance in mind
• New platforms
– Linux, OSX, Mono, Windows Phone*, Windows Store*
• New data stores
• In memory database
• Update-Database now split
– Apply-Migration
– Script-Migration
Resources
• Additional patterns
– http://www.asp.net/mvc/overview/older-versions/getting-started-with-
ef-5-using-mvc-4/implementing-the-repository-and-unit-of-work-
patterns-in-an-asp-net-mvc-application
• Reducing Code First Database Chatter
– http://romiller.com/2014/06/10/reducing-code-first-database-chatter/
• EF7 Project home
– https://github.com/aspnet/EntityFramework
©2014 Microsoft Corporation. All rights reserved. Microsoft, Windows, Office, Azure, System Center, Dynamics 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.
©2014 Microsoft Corporation. All rights reserved. Microsoft, Windows, Office, Azure, System Center, Dynamics 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.

More Related Content

What's hot

Oracle SQL Developer Top 10 Tips & Tricks
Oracle SQL Developer Top 10 Tips & TricksOracle SQL Developer Top 10 Tips & Tricks
Oracle SQL Developer Top 10 Tips & Tricks
Jeff Smith
 
PHP Frameworks, or how I learnt to stop worrying and love the code
PHP Frameworks, or how I learnt to stop worrying and love the codePHP Frameworks, or how I learnt to stop worrying and love the code
PHP Frameworks, or how I learnt to stop worrying and love the code
Michal Juhas
 
PL/SQL Guilty Pleasures
PL/SQL Guilty PleasuresPL/SQL Guilty Pleasures
PL/SQL Guilty Pleasures
Steven Feuerstein
 
AskTOM Office Hours - Dynamic SQL in PL/SQL
AskTOM Office Hours - Dynamic SQL in PL/SQLAskTOM Office Hours - Dynamic SQL in PL/SQL
AskTOM Office Hours - Dynamic SQL in PL/SQL
Steven Feuerstein
 
Test Driven Development in AEM/CQ5
Test Driven Development in AEM/CQ5Test Driven Development in AEM/CQ5
Test Driven Development in AEM/CQ5
rtpaem
 
Take Full Advantage of the Oracle PL/SQL Compiler
Take Full Advantage of the Oracle PL/SQL CompilerTake Full Advantage of the Oracle PL/SQL Compiler
Take Full Advantage of the Oracle PL/SQL Compiler
Steven Feuerstein
 
DSL, Page Object and WebDriver – the path to reliable functional tests.pptx
DSL, Page Object and WebDriver – the path to reliable functional tests.pptxDSL, Page Object and WebDriver – the path to reliable functional tests.pptx
DSL, Page Object and WebDriver – the path to reliable functional tests.pptx
Mikalai Alimenkou
 
Introducing domain driven design - dogfood con 2018
Introducing domain driven design - dogfood con 2018Introducing domain driven design - dogfood con 2018
Introducing domain driven design - dogfood con 2018
Steven Smith
 
Unit Testing Oracle PL/SQL Code: utPLSQL, Excel and More
Unit Testing Oracle PL/SQL Code: utPLSQL, Excel and MoreUnit Testing Oracle PL/SQL Code: utPLSQL, Excel and More
Unit Testing Oracle PL/SQL Code: utPLSQL, Excel and More
Steven Feuerstein
 
Illustrated Code (ASE 2021)
Illustrated Code (ASE 2021)Illustrated Code (ASE 2021)
Using The Page Object Pattern
Using The Page Object PatternUsing The Page Object Pattern
Using The Page Object Pattern
Dante Briones
 
Improving the Design of Existing Software
Improving the Design of Existing SoftwareImproving the Design of Existing Software
Improving the Design of Existing Software
Steven Smith
 
Automated Acceptance Tests in .NET
Automated Acceptance Tests in .NETAutomated Acceptance Tests in .NET
Automated Acceptance Tests in .NET
Wyn B. Van Devanter
 
Software development fundamentals
Software development fundamentalsSoftware development fundamentals
Software development fundamentals
Alfred Jett Grandeza
 
Improving the Quality of Existing Software
Improving the Quality of Existing SoftwareImproving the Quality of Existing Software
Improving the Quality of Existing Software
Steven Smith
 
OLD APEX and PL/SQL
OLD APEX and PL/SQLOLD APEX and PL/SQL
OLD APEX and PL/SQL
Steven Feuerstein
 
Test Driven Development in CQ5/AEM
Test Driven Development in CQ5/AEMTest Driven Development in CQ5/AEM
Test Driven Development in CQ5/AEM
Sagar Sane
 
Design Pattern Mastery - Momentum Dev Con 19 Apr 2018
Design Pattern Mastery - Momentum Dev Con 19 Apr 2018Design Pattern Mastery - Momentum Dev Con 19 Apr 2018
Design Pattern Mastery - Momentum Dev Con 19 Apr 2018
Steven Smith
 
Most Useful Design Patterns
Most Useful Design PatternsMost Useful Design Patterns
Most Useful Design Patterns
Steven Smith
 
Breaking Dependencies to Allow Unit Testing - DevIntersection Spring 2016
Breaking Dependencies to Allow Unit Testing - DevIntersection Spring 2016Breaking Dependencies to Allow Unit Testing - DevIntersection Spring 2016
Breaking Dependencies to Allow Unit Testing - DevIntersection Spring 2016
Steven Smith
 

What's hot (20)

Oracle SQL Developer Top 10 Tips & Tricks
Oracle SQL Developer Top 10 Tips & TricksOracle SQL Developer Top 10 Tips & Tricks
Oracle SQL Developer Top 10 Tips & Tricks
 
PHP Frameworks, or how I learnt to stop worrying and love the code
PHP Frameworks, or how I learnt to stop worrying and love the codePHP Frameworks, or how I learnt to stop worrying and love the code
PHP Frameworks, or how I learnt to stop worrying and love the code
 
PL/SQL Guilty Pleasures
PL/SQL Guilty PleasuresPL/SQL Guilty Pleasures
PL/SQL Guilty Pleasures
 
AskTOM Office Hours - Dynamic SQL in PL/SQL
AskTOM Office Hours - Dynamic SQL in PL/SQLAskTOM Office Hours - Dynamic SQL in PL/SQL
AskTOM Office Hours - Dynamic SQL in PL/SQL
 
Test Driven Development in AEM/CQ5
Test Driven Development in AEM/CQ5Test Driven Development in AEM/CQ5
Test Driven Development in AEM/CQ5
 
Take Full Advantage of the Oracle PL/SQL Compiler
Take Full Advantage of the Oracle PL/SQL CompilerTake Full Advantage of the Oracle PL/SQL Compiler
Take Full Advantage of the Oracle PL/SQL Compiler
 
DSL, Page Object and WebDriver – the path to reliable functional tests.pptx
DSL, Page Object and WebDriver – the path to reliable functional tests.pptxDSL, Page Object and WebDriver – the path to reliable functional tests.pptx
DSL, Page Object and WebDriver – the path to reliable functional tests.pptx
 
Introducing domain driven design - dogfood con 2018
Introducing domain driven design - dogfood con 2018Introducing domain driven design - dogfood con 2018
Introducing domain driven design - dogfood con 2018
 
Unit Testing Oracle PL/SQL Code: utPLSQL, Excel and More
Unit Testing Oracle PL/SQL Code: utPLSQL, Excel and MoreUnit Testing Oracle PL/SQL Code: utPLSQL, Excel and More
Unit Testing Oracle PL/SQL Code: utPLSQL, Excel and More
 
Illustrated Code (ASE 2021)
Illustrated Code (ASE 2021)Illustrated Code (ASE 2021)
Illustrated Code (ASE 2021)
 
Using The Page Object Pattern
Using The Page Object PatternUsing The Page Object Pattern
Using The Page Object Pattern
 
Improving the Design of Existing Software
Improving the Design of Existing SoftwareImproving the Design of Existing Software
Improving the Design of Existing Software
 
Automated Acceptance Tests in .NET
Automated Acceptance Tests in .NETAutomated Acceptance Tests in .NET
Automated Acceptance Tests in .NET
 
Software development fundamentals
Software development fundamentalsSoftware development fundamentals
Software development fundamentals
 
Improving the Quality of Existing Software
Improving the Quality of Existing SoftwareImproving the Quality of Existing Software
Improving the Quality of Existing Software
 
OLD APEX and PL/SQL
OLD APEX and PL/SQLOLD APEX and PL/SQL
OLD APEX and PL/SQL
 
Test Driven Development in CQ5/AEM
Test Driven Development in CQ5/AEMTest Driven Development in CQ5/AEM
Test Driven Development in CQ5/AEM
 
Design Pattern Mastery - Momentum Dev Con 19 Apr 2018
Design Pattern Mastery - Momentum Dev Con 19 Apr 2018Design Pattern Mastery - Momentum Dev Con 19 Apr 2018
Design Pattern Mastery - Momentum Dev Con 19 Apr 2018
 
Most Useful Design Patterns
Most Useful Design PatternsMost Useful Design Patterns
Most Useful Design Patterns
 
Breaking Dependencies to Allow Unit Testing - DevIntersection Spring 2016
Breaking Dependencies to Allow Unit Testing - DevIntersection Spring 2016Breaking Dependencies to Allow Unit Testing - DevIntersection Spring 2016
Breaking Dependencies to Allow Unit Testing - DevIntersection Spring 2016
 

Viewers also liked

05 managing transactions
05   managing transactions05   managing transactions
05 managing transactions
Марина Босова
 
03 managing relationships
03   managing relationships03   managing relationships
03 managing relationships
Марина Босова
 
01 introduction to entity framework
01   introduction to entity framework01   introduction to entity framework
01 introduction to entity framework
Марина Босова
 
02 beginning code first
02   beginning code first02   beginning code first
02 beginning code first
Марина Босова
 
Introduction to UML
Introduction to UMLIntroduction to UML
000 introduction
000 introduction000 introduction
000 introduction
sivorka
 
001 hosting
001 hosting001 hosting
001 hosting
sivorka
 
презентация привязка модели и валидация данных
презентация   привязка модели и валидация данныхпрезентация   привязка модели и валидация данных
презентация привязка модели и валидация данных
sivorka
 
навигация и валидаторы презентация
навигация и валидаторы   презентациянавигация и валидаторы   презентация
навигация и валидаторы презентация
sivorka
 
05 cерверные элементы управления презентация
05 cерверные элементы управления   презентация05 cерверные элементы управления   презентация
05 cерверные элементы управления презентация
sivorka
 
Mva stf module 6 - rus
Mva stf module 6 - rusMva stf module 6 - rus
Mva stf module 6 - rus
Maxim Shaptala
 
Mva stf module 5 - rus
Mva stf module 5 - rusMva stf module 5 - rus
Mva stf module 5 - rus
Maxim Shaptala
 
Testing po
Testing poTesting po
Testing po
Marina Bosova
 
Mva stf module 1 - rus
Mva stf module 1 - rusMva stf module 1 - rus
Mva stf module 1 - rus
Maxim Shaptala
 
Mva stf module 3 - rus
Mva stf module 3 - rusMva stf module 3 - rus
Mva stf module 3 - rus
Maxim Shaptala
 
Mva stf module 4 - rus
Mva stf module 4 - rusMva stf module 4 - rus
Mva stf module 4 - rus
Maxim Shaptala
 
Mva stf module 2 - rus
Mva stf module 2 - rusMva stf module 2 - rus
Mva stf module 2 - rus
Maxim Shaptala
 
Getting started with angular js
Getting started with angular jsGetting started with angular js
Getting started with angular js
Maurice De Beijer [MVP]
 
Team Foundation Server Process Templates For Effective Project Management
Team Foundation Server Process Templates For Effective Project ManagementTeam Foundation Server Process Templates For Effective Project Management
Team Foundation Server Process Templates For Effective Project Management
Aaron Bjork
 

Viewers also liked (20)

05 managing transactions
05   managing transactions05   managing transactions
05 managing transactions
 
03 managing relationships
03   managing relationships03   managing relationships
03 managing relationships
 
01 introduction to entity framework
01   introduction to entity framework01   introduction to entity framework
01 introduction to entity framework
 
02 beginning code first
02   beginning code first02   beginning code first
02 beginning code first
 
Introduction to UML
Introduction to UMLIntroduction to UML
Introduction to UML
 
000 introduction
000 introduction000 introduction
000 introduction
 
001 hosting
001 hosting001 hosting
001 hosting
 
презентация привязка модели и валидация данных
презентация   привязка модели и валидация данныхпрезентация   привязка модели и валидация данных
презентация привязка модели и валидация данных
 
навигация и валидаторы презентация
навигация и валидаторы   презентациянавигация и валидаторы   презентация
навигация и валидаторы презентация
 
05 cерверные элементы управления презентация
05 cерверные элементы управления   презентация05 cерверные элементы управления   презентация
05 cерверные элементы управления презентация
 
Mva stf module 6 - rus
Mva stf module 6 - rusMva stf module 6 - rus
Mva stf module 6 - rus
 
Mva stf module 5 - rus
Mva stf module 5 - rusMva stf module 5 - rus
Mva stf module 5 - rus
 
Testing po
Testing poTesting po
Testing po
 
Mva stf module 1 - rus
Mva stf module 1 - rusMva stf module 1 - rus
Mva stf module 1 - rus
 
Mva stf module 3 - rus
Mva stf module 3 - rusMva stf module 3 - rus
Mva stf module 3 - rus
 
Mva stf module 4 - rus
Mva stf module 4 - rusMva stf module 4 - rus
Mva stf module 4 - rus
 
Mva stf module 2 - rus
Mva stf module 2 - rusMva stf module 2 - rus
Mva stf module 2 - rus
 
Getting started with angular js
Getting started with angular jsGetting started with angular js
Getting started with angular js
 
jQuery for beginners
jQuery for beginnersjQuery for beginners
jQuery for beginners
 
Team Foundation Server Process Templates For Effective Project Management
Team Foundation Server Process Templates For Effective Project ManagementTeam Foundation Server Process Templates For Effective Project Management
Team Foundation Server Process Templates For Effective Project Management
 

Similar to 06 integrating extra features and looking forward

Getting Started with Sql Server Compact Edition
Getting Started with Sql Server Compact EditionGetting Started with Sql Server Compact Edition
Getting Started with Sql Server Compact Edition
DonRobins
 
Getting Started with SQL Server Compact Edition 3.51
Getting Started with SQL Server Compact Edition 3.51Getting Started with SQL Server Compact Edition 3.51
Getting Started with SQL Server Compact Edition 3.51
Mark Ginnebaugh
 
Alfresco Business Reporting - Tech Talk Live 20130501
Alfresco Business Reporting - Tech Talk Live 20130501Alfresco Business Reporting - Tech Talk Live 20130501
Alfresco Business Reporting - Tech Talk Live 20130501
Tjarda Peelen
 
01 overview-and-setup
01 overview-and-setup01 overview-and-setup
01 overview-and-setupsnopteck
 
Codeigniter
CodeigniterCodeigniter
Codeigniter
Joram Salinas
 
Spring data jpa are used to develop spring applications
Spring data jpa are used to develop spring applicationsSpring data jpa are used to develop spring applications
Spring data jpa are used to develop spring applications
michaelaaron25322
 
Sql interview question part 9
Sql interview question part 9Sql interview question part 9
Sql interview question part 9
kaashiv1
 
Sql interview-question-part-9
Sql interview-question-part-9Sql interview-question-part-9
Sql interview-question-part-9kaashiv1
 
Ebook9
Ebook9Ebook9
Ebook9
kaashiv1
 
Twelve Factor - Designing for Change
Twelve Factor - Designing for ChangeTwelve Factor - Designing for Change
Twelve Factor - Designing for Change
Eric Wyles
 
Integration-Monday-Terraform-Serverless
Integration-Monday-Terraform-ServerlessIntegration-Monday-Terraform-Serverless
Integration-Monday-Terraform-Serverless
BizTalk360
 
Oracle Database Cloud Service
Oracle Database Cloud ServiceOracle Database Cloud Service
Oracle Database Cloud Service
Jean-Philippe PINTE
 
KYSUC - Keep Your Schema Under Control
KYSUC - Keep Your Schema Under ControlKYSUC - Keep Your Schema Under Control
KYSUC - Keep Your Schema Under Control
Coimbra JUG
 
Dev Ops for systems of record - Talk at Agile Australia 2015
Dev Ops for systems of record - Talk at Agile Australia 2015Dev Ops for systems of record - Talk at Agile Australia 2015
Dev Ops for systems of record - Talk at Agile Australia 2015
Mirco Hering
 
Introduction to CakePHP
Introduction to CakePHPIntroduction to CakePHP
Introduction to CakePHP
mohamedsamirgalal
 
Introduction to CakePHP
Introduction to CakePHPIntroduction to CakePHP
Introduction to CakePHP
mohamedsamirgalal
 
Standardizing and Managing Your Infrastructure - MOSC 2011
Standardizing and Managing Your Infrastructure - MOSC 2011Standardizing and Managing Your Infrastructure - MOSC 2011
Standardizing and Managing Your Infrastructure - MOSC 2011
Brian Ritchie
 
01 demystifying mysq-lfororacledbaanddeveloperv1
01 demystifying mysq-lfororacledbaanddeveloperv101 demystifying mysq-lfororacledbaanddeveloperv1
01 demystifying mysq-lfororacledbaanddeveloperv1Ivan Ma
 
Impact of cloud services on the work of oracle technology experts
Impact of cloud services on the work of oracle technology expertsImpact of cloud services on the work of oracle technology experts
Impact of cloud services on the work of oracle technology experts
Andreas Chatziantoniou
 

Similar to 06 integrating extra features and looking forward (20)

Getting Started with Sql Server Compact Edition
Getting Started with Sql Server Compact EditionGetting Started with Sql Server Compact Edition
Getting Started with Sql Server Compact Edition
 
Getting Started with SQL Server Compact Edition 3.51
Getting Started with SQL Server Compact Edition 3.51Getting Started with SQL Server Compact Edition 3.51
Getting Started with SQL Server Compact Edition 3.51
 
Alfresco Business Reporting - Tech Talk Live 20130501
Alfresco Business Reporting - Tech Talk Live 20130501Alfresco Business Reporting - Tech Talk Live 20130501
Alfresco Business Reporting - Tech Talk Live 20130501
 
01 overview-and-setup
01 overview-and-setup01 overview-and-setup
01 overview-and-setup
 
Codeigniter
CodeigniterCodeigniter
Codeigniter
 
Spring data jpa are used to develop spring applications
Spring data jpa are used to develop spring applicationsSpring data jpa are used to develop spring applications
Spring data jpa are used to develop spring applications
 
Ebook9
Ebook9Ebook9
Ebook9
 
Sql interview question part 9
Sql interview question part 9Sql interview question part 9
Sql interview question part 9
 
Sql interview-question-part-9
Sql interview-question-part-9Sql interview-question-part-9
Sql interview-question-part-9
 
Ebook9
Ebook9Ebook9
Ebook9
 
Twelve Factor - Designing for Change
Twelve Factor - Designing for ChangeTwelve Factor - Designing for Change
Twelve Factor - Designing for Change
 
Integration-Monday-Terraform-Serverless
Integration-Monday-Terraform-ServerlessIntegration-Monday-Terraform-Serverless
Integration-Monday-Terraform-Serverless
 
Oracle Database Cloud Service
Oracle Database Cloud ServiceOracle Database Cloud Service
Oracle Database Cloud Service
 
KYSUC - Keep Your Schema Under Control
KYSUC - Keep Your Schema Under ControlKYSUC - Keep Your Schema Under Control
KYSUC - Keep Your Schema Under Control
 
Dev Ops for systems of record - Talk at Agile Australia 2015
Dev Ops for systems of record - Talk at Agile Australia 2015Dev Ops for systems of record - Talk at Agile Australia 2015
Dev Ops for systems of record - Talk at Agile Australia 2015
 
Introduction to CakePHP
Introduction to CakePHPIntroduction to CakePHP
Introduction to CakePHP
 
Introduction to CakePHP
Introduction to CakePHPIntroduction to CakePHP
Introduction to CakePHP
 
Standardizing and Managing Your Infrastructure - MOSC 2011
Standardizing and Managing Your Infrastructure - MOSC 2011Standardizing and Managing Your Infrastructure - MOSC 2011
Standardizing and Managing Your Infrastructure - MOSC 2011
 
01 demystifying mysq-lfororacledbaanddeveloperv1
01 demystifying mysq-lfororacledbaanddeveloperv101 demystifying mysq-lfororacledbaanddeveloperv1
01 demystifying mysq-lfororacledbaanddeveloperv1
 
Impact of cloud services on the work of oracle technology experts
Impact of cloud services on the work of oracle technology expertsImpact of cloud services on the work of oracle technology experts
Impact of cloud services on the work of oracle technology experts
 

Recently uploaded

Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
Atul Kumar Singh
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
Jisc
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
DhatriParmar
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
Nguyen Thanh Tu Collection
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
EugeneSaldivar
 
678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf
CarlosHernanMontoyab2
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
MIRIAMSALINAS13
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
Jisc
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
Levi Shapiro
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Thiyagu K
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
Anna Sz.
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
TechSoup
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
Tamralipta Mahavidyalaya
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
joachimlavalley1
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
Vikramjit Singh
 

Recently uploaded (20)

Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
 
678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
 

06 integrating extra features and looking forward

  • 1. 06 | Integrating extra features and looking forward Christopher Harrison | Content Developer, Microsoft Adam Tuliper | Technical Evangelist, Microsoft
  • 2. Module Overview • Stored procedures • Increasing user experience with concurrency detection • A few best practices • Looking forward with Entity Framework 7
  • 4. Store procedures • Why use stored procedures? – Single point to secure – easier permissions – Know exactly how DB is being queries • Limits dynamic sql – Still possible with sprocs, just more manual effort • In general performance is _not_ a reason – Virtually the same as sql query (pendulum swings both ways)
  • 5. Stored procedures • Support came in EF 6 – Only Fluent API based • In the past could use procs manually – var album = Database.SqlQuery<TriviaOption>("dbo.Proc…."); • Could map in the designer (which is going away) • Code first will generate procedures for – Insert, Delete, Update • Wait – why no Select?
  • 7. Increasing user experience with concurrency detection
  • 8. Concurrency • As Christopher showed, easy to implement via concurrency token – [TimeStamp] – modelBuilder.Entity<YourEntity>() .Property(e => e.Timestamp) .IsRowVersion(); • Change detection can be enhanced via MVC Action Filters • Let’s give the user the choice on how to proceed
  • 10. A few best practices
  • 11. Helpful hints in a web world • Since the web layers (controller to view) are disconnected – Always convert results to IEnumerable via .ToList() • Ex. context.Albums.Where(o=>o.Title.Contains(search).ToList() • Disable lazy loading in web environments – context.Configuration.LazyLoadingEnabled = false; – Use .Include to load related entities – context.Albums.Include(o=>o.AlbumDetails) • DbContext is not thread safe. Do not cache it! – Always dispose DbContext when done
  • 12. Context lifetime • When context is gone, connection is gone – Can’t (and shouldn’t) use connection from MVC view – Get data, send to view • Always execute result set when needed before exiting using() using (var context = new MusicContext()) { var albums = context.Albums .Where(o=>o.Title.Contains(search)) .ToList()); return View(albums); }
  • 13. Watch out for… • For complex joins, keep an eye on queries – Remember context.Database.Log = s => Debug.WriteLine(s); • Doing lots of inserts? AutoDetectChangesEnabled = false; – EF detects changes on add to context and on save – Can turn off and on again in same context lifetime { context.Configuration.AutoDetectChangesEnabled = false; Do something context.Configuration.AutoDetectChangesEnabled = true; }
  • 14. Async when appropriate • EF supports async queries – Async allows current thread to be used elsewhere • Useful in case of network, db delays (long operations) – Although not all the time, caution of overloading db public async Task<ActionResult> Create(…) { if (ModelState.IsValid) { db.Albums.Add(album); await db.SaveChangesAsync(); return RedirectToAction("Index"); } return View(album); }
  • 15. Consider Connection resiliency • This is a connection retry policy • Works great with async • Four modes – DefaultExecutionStrategy – DefaultSqlExecutionStrategy – DbExecutionStrategy – SqlAzureExecutionStrategy • throws RetryLimitExceededException
  • 17. Looking forward with Entity Framework 7
  • 18. Notable new features • Designer has been removed – Code First Only • Rewritten from ground up with performance in mind • New platforms – Linux, OSX, Mono, Windows Phone*, Windows Store* • New data stores • In memory database • Update-Database now split – Apply-Migration – Script-Migration
  • 19. Resources • Additional patterns – http://www.asp.net/mvc/overview/older-versions/getting-started-with- ef-5-using-mvc-4/implementing-the-repository-and-unit-of-work- patterns-in-an-asp-net-mvc-application • Reducing Code First Database Chatter – http://romiller.com/2014/06/10/reducing-code-first-database-chatter/ • EF7 Project home – https://github.com/aspnet/EntityFramework
  • 20. ©2014 Microsoft Corporation. All rights reserved. Microsoft, Windows, Office, Azure, System Center, Dynamics 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. ©2014 Microsoft Corporation. All rights reserved. Microsoft, Windows, Office, Azure, System Center, Dynamics 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.

Editor's Notes

  1. 1
  2. modelBuilder    .Entity<Album>()    .MapToStoredProcedures(); modelBuilder     .Entity<Album>()     .MapToStoredProcedures(s =>       s.Update(u => u.HasName(“Blog_"))        .Delete(d => d.HasName("delete_blog"))        .Insert(i => i.HasName("insert_blog"))); modelBuilder.Entity<TriviaOption>().MapToStoredProcedures(p => p.Insert(proc => proc.HasName("Proc_AddAlbum") .Result(r => r.Id,"id")));
  3. ToListAsync await db.SaveChangesAsync public async Task<ActionResult> Return task [HttpPost] [ValidateAntiForgeryToken] public async Task<ActionResult> Create([Bind(Include = "AlbumId,GenreId,ArtistId,Title,Price,AlbumArtUrl")] Album album) { if (ModelState.IsValid) { db.Albums.Add(album); await db.SaveChangesAsync(); return RedirectToAction("Index"); } return View(album); }
  4. https://code.msdn.microsoft.com/ASPNET-MVC-Application-b01a9fe8
  5. Change method to be async for save