Note: This article was originally published in 2011. Some steps, commands, or software versions may have changed. Check the current .Net documentation for the latest information.
Prerequisites
Before you begin, make sure you have:
- Visual Studio or .NET CLI installed
- .NET Framework or .NET Core SDK
- Basic C# programming knowledge
| After writing code using entity framework for sometime and seeing the code base continue to grow I realized the importance of coding with performance in mind. There are things that come to mind like eager loading, but that alone won’t do much as your application continues to grow. Below are some key best practices I found on the web as well as links worthwhile examining as you look for ways to improve your performance: Best Practice | Impact | Required Refactoring |
|---|---|---|
| Pre-generated Your View | Major | Minor |
| Use Small EDMX Files | Minor | Moderate |
| Create Smart Connection Strings | Minor | Minor |
| Disable Change Tracking | Minor | Minor |
| Use Compiled Queries | Moderate | Moderate |
| Be Careful With Includes | Moderate | Major |
| Source: http://www.codeproject.com/KB/database/PerfEntityFramework.aspx You can also learn more at: (http://msdn.microsoft.com/en-us/library/bb896325.aspx “Managing connections and transactions”) |
Summary
You’ve successfully learned improve the performance of the entity framework. If you run into any issues, double-check the prerequisites and ensure your .Net environment is properly configured.
Related Articles
- Entity Framework 4: Any way to know the plural form of an Entity Type?
- Entity Framework - Why can’t I see the child entities of my entity
- LINQ to Entities does not recognize the method ‘get_Item(Int32)’ method.
- Enumeration: What are the different SharePoint permission levels and their enumeration values?