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

PDF
C++ 11 Style : A Touch of Class
Yogendra Rampuria
 
PPTX
04 managing the database
Марина Босова
 
PPTX
01 introduction to entity framework
Maxim Shaptala
 
PDF
iOS development best practices
Michal Juhas
 
PDF
Building an Eclipse plugin to recommend changes to developers
kim.mens
 
ZIP
Promises in JavaScript with jQuery
Ryan Blunden
 
PDF
Six simple steps to unit testing happiness
Steven Feuerstein
 
PPTX
Polyglot engineering
Klaus Salchner
 
C++ 11 Style : A Touch of Class
Yogendra Rampuria
 
04 managing the database
Марина Босова
 
01 introduction to entity framework
Maxim Shaptala
 
iOS development best practices
Michal Juhas
 
Building an Eclipse plugin to recommend changes to developers
kim.mens
 
Promises in JavaScript with jQuery
Ryan Blunden
 
Six simple steps to unit testing happiness
Steven Feuerstein
 
Polyglot engineering
Klaus Salchner
 

What's hot (20)

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

Viewers also liked (20)

PPTX
05 managing transactions
Марина Босова
 
PPTX
03 managing relationships
Марина Босова
 
PPTX
01 introduction to entity framework
Марина Босова
 
PPTX
02 beginning code first
Марина Босова
 
PDF
000 introduction
sivorka
 
PDF
001 hosting
sivorka
 
PDF
презентация привязка модели и валидация данных
sivorka
 
PDF
навигация и валидаторы презентация
sivorka
 
PDF
05 cерверные элементы управления презентация
sivorka
 
PPTX
Mva stf module 6 - rus
Maxim Shaptala
 
PPTX
Mva stf module 5 - rus
Maxim Shaptala
 
PPTX
Testing po
Marina Bosova
 
PPTX
Mva stf module 1 - rus
Maxim Shaptala
 
PPTX
Mva stf module 3 - rus
Maxim Shaptala
 
PPTX
Mva stf module 4 - rus
Maxim Shaptala
 
PPTX
Mva stf module 2 - rus
Maxim Shaptala
 
PPT
Getting started with angular js
Maurice De Beijer [MVP]
 
PDF
jQuery for beginners
Siva Arunachalam
 
PPTX
Team Foundation Server Process Templates For Effective Project Management
Aaron Bjork
 
05 managing transactions
Марина Босова
 
03 managing relationships
Марина Босова
 
01 introduction to entity framework
Марина Босова
 
02 beginning code first
Марина Босова
 
000 introduction
sivorka
 
001 hosting
sivorka
 
презентация привязка модели и валидация данных
sivorka
 
навигация и валидаторы презентация
sivorka
 
05 cерверные элементы управления презентация
sivorka
 
Mva stf module 6 - rus
Maxim Shaptala
 
Mva stf module 5 - rus
Maxim Shaptala
 
Testing po
Marina Bosova
 
Mva stf module 1 - rus
Maxim Shaptala
 
Mva stf module 3 - rus
Maxim Shaptala
 
Mva stf module 4 - rus
Maxim Shaptala
 
Mva stf module 2 - rus
Maxim Shaptala
 
Getting started with angular js
Maurice De Beijer [MVP]
 
jQuery for beginners
Siva Arunachalam
 
Team Foundation Server Process Templates For Effective Project Management
Aaron Bjork
 
Ad

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

DOCX
Entity framework (EF) 7
Paul Graham
 
PPTX
State of entity framework
David Paquette
 
PPTX
Entity framework advanced
Usama Nada
 
PDF
[FREE PDF sample] Programming Entity Framework DbContext 1st Edition Julia Le...
pontyrincoe
 
PPTX
Learn Mastering-the-NET-Interview 2.pptx
surajkumartpoint
 
PPTX
Real World MVC
James Johnson
 
PDF
Entity Framework Core Cookbook 2nd Edition Ricardo Peres
yuvejulpah
 
PPTX
MVC and Entity Framework 4
James Johnson
 
PPTX
Building data centric applications for web, desktop and mobile with Entity Fr...
Microsoft Developer Network (MSDN) - Belgium and Luxembourg
 
PPTX
MVC and Entity Framework
James Johnson
 
PPTX
Entity Framework 7: What's New?
Ricardo Peres
 
PPTX
Be04 introduction to ef 6.0
DotNetCampus
 
PPTX
What's New in .Net 4.5
Malam Team
 
PDF
.NET Core, ASP.NET Core Course, Session 16
Amin Mesbahi
 
PPTX
Entity Framework 4
Stefano Paluello
 
PDF
Getting started with entity framework 6 code first using mvc 5
Ehtsham Khan
 
PPTX
dotNet Miami - June 21, 2012: Richie Rump: Entity Framework: Code First and M...
dotNet Miami
 
PPTX
Tuga it 2016 improving your application performance
Nuno Caneco
 
PPTX
05 entity framework
glubox
 
PPTX
Кирилл Безпалый, .NET Developer, Ciklum
Alina Vilk
 
Entity framework (EF) 7
Paul Graham
 
State of entity framework
David Paquette
 
Entity framework advanced
Usama Nada
 
[FREE PDF sample] Programming Entity Framework DbContext 1st Edition Julia Le...
pontyrincoe
 
Learn Mastering-the-NET-Interview 2.pptx
surajkumartpoint
 
Real World MVC
James Johnson
 
Entity Framework Core Cookbook 2nd Edition Ricardo Peres
yuvejulpah
 
MVC and Entity Framework 4
James Johnson
 
Building data centric applications for web, desktop and mobile with Entity Fr...
Microsoft Developer Network (MSDN) - Belgium and Luxembourg
 
MVC and Entity Framework
James Johnson
 
Entity Framework 7: What's New?
Ricardo Peres
 
Be04 introduction to ef 6.0
DotNetCampus
 
What's New in .Net 4.5
Malam Team
 
.NET Core, ASP.NET Core Course, Session 16
Amin Mesbahi
 
Entity Framework 4
Stefano Paluello
 
Getting started with entity framework 6 code first using mvc 5
Ehtsham Khan
 
dotNet Miami - June 21, 2012: Richie Rump: Entity Framework: Code First and M...
dotNet Miami
 
Tuga it 2016 improving your application performance
Nuno Caneco
 
05 entity framework
glubox
 
Кирилл Безпалый, .NET Developer, Ciklum
Alina Vilk
 

Recently uploaded (20)

PPTX
HISTORY COLLECTION FOR PSYCHIATRIC PATIENTS.pptx
PoojaSen20
 
PPTX
CONCEPT OF CHILD CARE. pptx
AneetaSharma15
 
DOCX
pgdei-UNIT -V Neurological Disorders & developmental disabilities
JELLA VISHNU DURGA PRASAD
 
PPTX
HEALTH CARE DELIVERY SYSTEM - UNIT 2 - GNM 3RD YEAR.pptx
Priyanshu Anand
 
PDF
The-Invisible-Living-World-Beyond-Our-Naked-Eye chapter 2.pdf/8th science cur...
Sandeep Swamy
 
PPTX
Artificial Intelligence in Gastroentrology: Advancements and Future Presprec...
AyanHossain
 
PPTX
An introduction to Dialogue writing.pptx
drsiddhantnagine
 
PDF
The Minister of Tourism, Culture and Creative Arts, Abla Dzifa Gomashie has e...
nservice241
 
PPTX
Tips Management in Odoo 18 POS - Odoo Slides
Celine George
 
PDF
Antianginal agents, Definition, Classification, MOA.pdf
Prerana Jadhav
 
PPTX
Information Texts_Infographic on Forgetting Curve.pptx
Tata Sevilla
 
PPTX
How to Manage Leads in Odoo 18 CRM - Odoo Slides
Celine George
 
PDF
What is CFA?? Complete Guide to the Chartered Financial Analyst Program
sp4989653
 
PPTX
Applications of matrices In Real Life_20250724_091307_0000.pptx
gehlotkrish03
 
PPTX
BASICS IN COMPUTER APPLICATIONS - UNIT I
suganthim28
 
PPTX
Measures_of_location_-_Averages_and__percentiles_by_DR SURYA K.pptx
Surya Ganesh
 
PPTX
Python-Application-in-Drug-Design by R D Jawarkar.pptx
Rahul Jawarkar
 
PDF
RA 12028_ARAL_Orientation_Day-2-Sessions_v2.pdf
Seven De Los Reyes
 
PPTX
CARE OF UNCONSCIOUS PATIENTS .pptx
AneetaSharma15
 
PPTX
Artificial-Intelligence-in-Drug-Discovery by R D Jawarkar.pptx
Rahul Jawarkar
 
HISTORY COLLECTION FOR PSYCHIATRIC PATIENTS.pptx
PoojaSen20
 
CONCEPT OF CHILD CARE. pptx
AneetaSharma15
 
pgdei-UNIT -V Neurological Disorders & developmental disabilities
JELLA VISHNU DURGA PRASAD
 
HEALTH CARE DELIVERY SYSTEM - UNIT 2 - GNM 3RD YEAR.pptx
Priyanshu Anand
 
The-Invisible-Living-World-Beyond-Our-Naked-Eye chapter 2.pdf/8th science cur...
Sandeep Swamy
 
Artificial Intelligence in Gastroentrology: Advancements and Future Presprec...
AyanHossain
 
An introduction to Dialogue writing.pptx
drsiddhantnagine
 
The Minister of Tourism, Culture and Creative Arts, Abla Dzifa Gomashie has e...
nservice241
 
Tips Management in Odoo 18 POS - Odoo Slides
Celine George
 
Antianginal agents, Definition, Classification, MOA.pdf
Prerana Jadhav
 
Information Texts_Infographic on Forgetting Curve.pptx
Tata Sevilla
 
How to Manage Leads in Odoo 18 CRM - Odoo Slides
Celine George
 
What is CFA?? Complete Guide to the Chartered Financial Analyst Program
sp4989653
 
Applications of matrices In Real Life_20250724_091307_0000.pptx
gehlotkrish03
 
BASICS IN COMPUTER APPLICATIONS - UNIT I
suganthim28
 
Measures_of_location_-_Averages_and__percentiles_by_DR SURYA K.pptx
Surya Ganesh
 
Python-Application-in-Drug-Design by R D Jawarkar.pptx
Rahul Jawarkar
 
RA 12028_ARAL_Orientation_Day-2-Sessions_v2.pdf
Seven De Los Reyes
 
CARE OF UNCONSCIOUS PATIENTS .pptx
AneetaSharma15
 
Artificial-Intelligence-in-Drug-Discovery by R D Jawarkar.pptx
Rahul Jawarkar
 

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

  • #2: 1
  • #7: 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")));
  • #15: 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); }
  • #16: https://code.msdn.microsoft.com/ASPNET-MVC-Application-b01a9fe8
  • #17: Change method to be async for save