Home >Backend Development >C++ >Why Does Microsoft Advocate Asynchronous Calls in its EF 6 ASP.NET MVC 5 Tutorial?
The latest EF 6 tutorial for ASP.NET MVC 5 strongly promotes asynchronous database access, exemplified by code like:
<code>Department department = await db.Departments.FindAsync(id);</code>
Let's weigh the pros and cons of asynchronous versus synchronous approaches:
Asynchronous Advantages:
Synchronous Advantages:
When to Choose Asynchronous:
Microsoft advises using asynchronous calls in ASP.NET applications when interacting with high-latency services, such as web services and lengthy database operations. For low-latency operations (database or file system access), synchronous calls are usually more efficient.
Reasons Behind Microsoft's Recommendation:
The EF team's emphasis on asynchronous programming might stem from:
It's crucial to remember that asynchronous calls should only be implemented when they provide substantial advantages. Mixing synchronous and asynchronous patterns within a single application is perfectly acceptable.
The above is the detailed content of Why Does Microsoft Advocate Asynchronous Calls in its EF 6 ASP.NET MVC 5 Tutorial?. For more information, please follow other related articles on the PHP Chinese website!